Tag: cloudformationTemplate

CloudFormation template to create CodeDeploy application

The requirement is to use cloudformation stacks to create CodeDeploy application and deployment group with required configuration. Although we get the information about which resources to use its all bits and pieces. It took me couple of hours to understand and write the CloudFormation template and use it to create codedeploy application.

Basically we have to create two cloudformation stacks.
1. stack1 – to create codedeploy application
2. stack2 – to create deployment group and other parameters and associate it with the codedeploy application created.
The AWS::CodeDeploy::Application resource creates an AWS CodeDeploy application. You can use the AWS::CodeDeploy::DeploymentGroup resource to associate the application with an AWS CodeDeploy deployment group.
stack1 – codedeploy-appName.json
creates codedeploy application
 
stack2 – codedeploy-deployGrp.json
associates with codedeploy application, creates deployment group, deployment config name, adds ec2 tag filters and ServiceRoleArn
Below is the template
codedploy-appName.json
{
“AWSTemplateFormatVersion”: “2010-09-09”,

“Resources”: {
“MyCodeDeployApp”: {
“Type” : “AWS::CodeDeploy::Application”,
“Properties” : {
“ApplicationName” : “App11”
}
}
}
}

codedploy-deployGrp.json
{
“AWSTemplateFormatVersion”: “2010-09-09”,

“Parameters”: {
“DeploymentConfigurationName”: {
“Description”: “With predefined configurations, you can deploy application revisions to one instance at a time, half of the instances at a time, or all the instances at once.”,
“Type”: “String”,
“Default”: “CodeDeployDefault.OneAtATime”,
“ConstraintDescription”: “Must be a valid Deployment configuration name”
}
},

“Resources”: {
“MyCodeDeploy” : {
“Type” : “AWS::CodeDeploy::DeploymentGroup”,
“Properties” : {
“ApplicationName” : “App11”,
“DeploymentConfigName” : {
“Ref”: “DeploymentConfigurationName”
},
“DeploymentGroupName” : “DeployGrp11”,
“Ec2TagFilters” : [{
“Key” : “Name”,
“Type” : “KEY_AND_VALUE”,
“Value” : “App1-env”
}],
“ServiceRoleArn” : “arn:aws:iam::322340642362:role/deployRole”
}
}
}
}

Advertisements