Since we are about to make changes to the source code, you should use Git to create a new branch. You can do this via the command line or using the Eclipse IDE. Name the new branch new-implementation. To create and switch to a new branch in Eclipse perform the following steps:
In this case, we will use the command line.
git checkout -b new-implementation
to create and switch to the new branch.Download this file by browser in the virtual machine you are running.
Delete src and target folders.
Copy the contents of the extracted TravelBuddy folder (source folder) to the folder you just opened from the Eclip IDE (destination folder). You can delete the .ebextensions folder in the destination folder before performing the copy, or select Replace to ensure that the files and folders are overwritten correctly.
You will see in the .ebextensions folder there are 3 files, one is the parameters you need to update with the RDS endpoint, the other two are pre-generated with the codecommit setting - set-instance-credit-unlimited.config sshd. config.
Open env_vars.config file in .ebextensions folder and replace value to RDS endpoint:
option_settings:
- namespace: aws:elasticbeanstalk:application:environment
option_name: JDBC_CONNECTION_STRING
value: <REPLACE YOUR DETAIILS HERE>
You can get your RDS value by logging into the AWS Console, accessing the running RDS instance and getting the endpoint information from there, and adding it to the env_vars.
You can also get this parameter from the cloudformation stack in the Output section of the Cloudformation stack created at the beginning of the workshop.
You have just changing the source code, now you need to add the files you just changed to the new-implementation branch and commit it.
Use the terminal, access to TravelBuddy folder.
git status
to list changes of source code.git config --global user.email "you@example.com"
git config --global user.name awsstudent
git add .
to add changed files.git commit -m "Baseline implementation"
to commit the changes.git checkout master
to switch to master branch.git merge new-implementation
git status
command.It will take a few minutes to push code and running.
To make the application accessible to the database, update the security rule.
Open EC2 console.
Click Security Groups on the left menu.
In this part, we will speed up building by storing artifacts (e.g. java packages) in an S3 bucket that can be used on the next build.
cache:
paths:
- '/root/.m2/**/*'
Open the terminal.
Execute the below commnad to create a new caching bucket. Replace with the name you want.
aws s3 mb s3://cachingbucket-<YOURNAME-NO-SPACES>
The AWS CodeBuild needs to access to the cache bucket, so we need IAM permissions name. Open AWS Console and access IAM.
Select Policies tab and find CodeStar_travelbuddy_PermissionsBoundary policy.
{
"Sid": "CBCachePolicy",
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::cachingbucket-<YOURNAME-NO-SPACES>",
"arn:aws:s3:::cachingbucket-<YOURNAME-NO-SPACES>/*"
]
},
Select Save changes.
Open AWS Codestar and select your project’s Pipeline tab.