codedeploy-terraform
                                
                                 codedeploy-terraform copied to clipboard
                                
                                    codedeploy-terraform copied to clipboard
                            
                            
                            
                        CodeDeploy demo using Terraform and Sample application
CodeDeploy with Terraform Demo
- Generate an SSH key pair:
$ ssh-keygen -t rsa -f ~/.ssh/code-deploy-demo -C cd-demo -P ""
- Run terraform:
$ terraform init
$ terraform apply
Resources will be created in eu-west-1 region by default. Change region var if you want another region.
- From the output get the name of the s3 bucket created. If you get an output like this:
codedeploydemo-734.s3.amazonaws.com
then the name of the created bucket is codedeploydemo-734. Save this bucket name, you will upload the sample application revision to that bucket.
- Change directory into sample-app. And run the following command to create application revision and upload it to S3 bucket (make sure to change the name of the bucket [and region if you changed it in terraform]).
$ cd sample-app
$ aws --region eu-west-1 deploy push \
    --application-name Sample_App \
    --s3-location s3://codedeploydemo-734/SampleApp.zip
This command bundles the files from the current directory into a single archive file named SampleApp.zip, uploads the revision to the codedeploydemo-734 bucket, and registers information with AWS CodeDeploy about the uploaded revision.
- Create a deployment (make sure to change the name of the bucket [and region if you changed it in terraform]):
$ aws --region eu-west-1 deploy create-deployment \
    --application-name Sample_App \
    --deployment-config-name CodeDeployDefault.OneAtATime \
    --deployment-group-name Sample_DepGroup \
    --s3-location bucket=codedeploydemo-734,bundleType=zip,key=SampleApp.zip
- Access the Sample application by instace's public IP. Get the instance's public IP from terraform output and put it in your browser.