Setup your cloud development environment. This will create an instance of AWS Cloud9, a cloud-based integrated development environment (IDE) that will let you write, run, and debug software using just a web browser.
Launch the Cloud9 IDE and run the following command to complete the setup of the Cloud9 IDE environment. The launch URL for the Cloud9 IDE is an output of the stack which was just created. The output key is:
wget https://raw.githubusercontent.com/aws-samples/amazon-ecs-catsndogs-workshop/master/scripts/ide-build-script.sh -O ~/environment/ide-build-script.sh && \ chmod +x ~/environment/ide-build-script.sh && \ ~/environment/ide-build-script.sh
During the initial start-up of the Cloud9 IDE a number of steps will automatically run to prepare the environment for first use. The steps include cloning an AWS CodeCommit repository in to the AWS Cloud9 IDE workspace.
Create a new CodePipeline pipeline. The Source should be the AWS CodeCommit repository that was automatically created as part of the initial workshop setup. In the Build step, create a new CodeBuild project. For the build environment, use an image managed by AWS CodeBuild. Use the Ubuntu Docker image version 17.09.0.
Use the role with CatsnDogsBuild in the name.
In Advanced settings, add three environment variables:
Choose Amazon ECS for the Deployment provider, and configured the following values:
Cluster name: choose the cluster with catsndogs in the name.
Service name: choose the service with Dogs in the name
Image filename: enter imagedefinitions.json. This JSON file describes the service container name, image and tag
Use the IAM role with CatsnDogsPipeline in the name.
Using the Cloud9 IDE, edit the background color of the Dogs application, commit the changes and push them to the CodeCommit repository. This will tigger the CodePipeline pipeline and deploy the changes to production.
Copy the value of the LoadBalancerDNSName, created by the catsndogssetup CloudFormation stack that was deployed at the start of the workshop, in to you address bar of your web browser. The Dogs application page should appear with fancy new background color.
The build process for the dogs container image uses the AWS CLI to copy the latest dog memes from an S3 bucket. Although the images are publicly readable, any S3 operation requires AWS credentials. In this case, the credentials from the build environment need to be passed through to the container image build process, otherwise the build process will fail with “Unable to locate credentials”. More details can be found here: http://docs.aws.amazon.com/codebuild/latest/userguide/troubleshooting.html#troubleshooting-versions
Extension activity: Examine the buildspec.yml file in the CodeCommit repository, to understand the steps the CodeBuild project is taking to build and push the container image. How is the image tagged? How does the CodePipeline pipeline retrieve the tag, to use as a parameter when updating the CloudFormation stack?