Click Create service role if you never go to AWS CodeStar Service before.
FlightSpecialsAPI
DevAx-06
to the search bar and click Enter.FlightSpecialsAPI
cd C:\Users\Administrator\git\FlightSpecialsAPI
git checkout -b "new-implementation"
copy_files.sh C:\Users\Administrator\git\FlightSpecialsAPI
19. In the Eclipse IDE, right-click on the FlightSpecialsAPI project we imported
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>
<dependency>
<groupId>com.amazonaws.serverless</groupId>
<artifactId>aws-serverless-java-container-core</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.2.0</version>
</dependency>
CodeStarWorker-flightspecialsa-CloudFormation
to the search bar and press EnterIf you can’t find the role, it may be too early - CodeStar may still be provisioning the pipeline and may not yet have created the role. Check the progress of the provisioning in the CodeStar dashboard.
idevelop
to the search bar and press EnterThe swagger.yml file provided in the zip bundle is the definition for the API that exposes the microservice via Amazon API Gateway. It needs to be updated with details of your lab AWS Account Id and target AWS Region before you can deploy your microservice.
REPLACE_AWS_REGION
REPLACE_AWS_ACCOUNTID
cd C:\Users\Administrator\git\FlightSpecialsAPI
git status
28. Execute the below command to add in the changed files
git add .
git commit -m "Baseline implementation"
29. Execute the below command to switch back to the master branch
git checkout master
30. Execute the below command to merge the changes for your new-implementation branch into the master branch
git merge new-implementation
31. In the Eclipse IDE, right-click on the FlightSpecialsAPI project
You need to perform the push from Eclipse because the git credentials are embedded within the Eclipse environment. You could also configure the command line environment with the git credentials but that is beyond the scope of this lab.
It will take a few moments to push the code and commence the deployment. Checking in the source code and templates will trigger the pipeline to build and deploy the new implementation. AWS CodePipeline will now use CloudFormation to deploy the following resources:
While you have some time, spend a few minutes to explore the buildspec.yml, swagger.yml and template.yml files which define the Amazon API Gateway, AWS Lambda function and the build/deployment process through AWS CodeBuild. You will notice that the builspec.yml file uses the same AWS CLI command to package the deployment that you used when you manually packaged the HotelSpecials API earlier.
Do not execute these commands below, they are here as a reference!
mvn package shade:shade
aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template template-export.yml
The template.yml file uses the Serverless Application Model (SAM) transform to define the REST API, as opposed to how we approached this in the HotelSpecials API example. In HotelSpecials, the CloudFormation template used canonical CloudFormation to define the REST API so that it could be explicit about the API definition and include the swagger definition inline. The FlightSpecials example uses a more declarative approach and left the details to SAM. You are free to mix CloudFormation and SAM in the same template, as you can see from these examples.
If you see a JSON payload with no errors, you have successfully deployed an API and supporting Lambda function that queries the mySQL database. Notice how much quicker and easier that was to deploy without any manual intervention, and you didn’t even have to interact with the AWS CLI or Console? Everything was driven by the source control check-in process.
You are now ready to integrate these APIs with the TravelBuddy web site.