Application('TwitterProducerCodeDeployApplication', DependsOn=f'{SERVER_NAME}', ApplicationName='TwitterProducer')) deployment_group = template.add_resource( DeploymentGroup( 'DeploymentGroup', DependsOn=[f'{SERVER_NAME}', 'TwitterProducerCodeDeployApplication'], ApplicationName=Ref(code_deploy_application), Ec2TagFilters=[ Ec2TagFilters('TwitterProducerEc2Filter', Type='KEY_AND_VALUE', Key='Name', Value='twitter-producer') ], DeploymentGroupName='TwitterProducer', ServiceRoleArn=GetAtt(code_deploy_service_role, 'Arn'), DeploymentConfigName='CodeDeployDefault.OneAtATime', Deployment=Deployment( Description='First automated deployment', Revision=Revision( RevisionType='S3', S3Location=S3Location( Bucket='nicor-dev', Key= f'deployments/apps/twitter-to-kinesis/{deployment_commithash}.zip', BundleType='zip'))))) # outputs template.add_output([ Output('TwitterProducerEC2', Description='EC2 Instance',
template = Template() template.set_version("2010-09-09") auto_rollback_configuration = AutoRollbackConfiguration( Enabled=True, Events=["DEPLOYMENT_FAILURE"]) deployment_style = DeploymentStyle(DeploymentOption="WITH_TRAFFIC_CONTROL") elb_info_list = ElbInfoList(Name="DemoLoadBalancer") load_balancer_info = LoadBalancerInfo(ElbInfoList=[elb_info_list]) deployment_group = DeploymentGroup( "DemoDeploymentGroup", ApplicationName="DemoApplication", AutoRollbackConfiguration=auto_rollback_configuration, DeploymentStyle=deployment_style, LoadBalancerInfo=load_balancer_info, ServiceRoleArn="arn:aws:iam::0123456789:role/codedeploy-role", ) template.add_resource(deployment_group) # EC2 instances deployment_group_ec2 = DeploymentGroup( "DemoDeploymentGroupEC2Instances", DeploymentGroupName="DemoApplicationEc2Instances", ApplicationName="DemoApplicationEc2Instances", AutoRollbackConfiguration=auto_rollback_configuration, DeploymentStyle=DeploymentStyle( DeploymentOption="WITHOUT_TRAFFIC_CONTROL"), ServiceRoleArn="arn:aws:iam::0123456789:role/codedeploy-role", Ec2TagSet=Ec2TagSet(Ec2TagSetList=[
MaxSize="3", MinSize="0", TargetGroupARNs=[Ref(WebTargets)], VPCZoneIdentifier=VpcSubnets, )) ################### create deploy ###################### auto_rollback_configuration = AutoRollbackConfiguration( Enabled=True, Events=['DEPLOYMENT_FAILURE']) deployment_style = DeploymentStyle(DeploymentOption='WITH_TRAFFIC_CONTROL') tg_info_list = TargetGroupInfoList(Name=GetAtt(WebTargets, "TargetGroupName")) load_balancer_info = LoadBalancerInfo(TargetGroupInfoList=[tg_info_list]) cdapp = template.add_resource( Application("cdapp", ApplicationName="demoapp", ComputePlatform="Server")) deployment_group = DeploymentGroup( "DemoDeploymentGroup", ApplicationName=Ref(cdapp), AutoScalingGroups=[Ref(asg)], AutoRollbackConfiguration=auto_rollback_configuration, DeploymentStyle=deployment_style, LoadBalancerInfo=load_balancer_info, ServiceRoleArn='arn:aws:iam::364564756213:role/Admin') template.add_resource(deployment_group) print(template.to_yaml())
application = t.add_resource( Application(stackName, ApplicationName=stackName, ComputePlatform="Server")) deployment_groups = {} for role in roles: deployment_groups[role] = DeploymentGroup( stackName + role + "DeploymentGroup", DeploymentGroupName=role.capitalize(), ApplicationName=stackName, DependsOn=application, AutoRollbackConfiguration=AutoRollbackConfiguration( Enabled=True, Events=['DEPLOYMENT_FAILURE']), DeploymentStyle=DeploymentStyle( DeploymentOption='WITHOUT_TRAFFIC_CONTROL'), ServiceRoleArn=GetAtt(stackName + "CodeDeployServiceIAMRole", "Arn"), Ec2TagSet=Ec2TagSet(Ec2TagSetList=[ Ec2TagSetListObject(Ec2TagGroup=[ Ec2TagFilters(Key="Role", Type="KEY_AND_VALUE", Value=role), ]) ])) t.add_resource(deployment_groups[role]) """ Cloudformation Outputs """ t.add_output( Output( stackName + "vpcid",
template = Template() template.add_version('2010-09-09') auto_rollback_configuration = AutoRollbackConfiguration( Enabled=True, Events=['DEPLOYMENT_FAILURE']) deployment_style = DeploymentStyle(DeploymentOption='WITH_TRAFFIC_CONTROL') elb_info_list = ElbInfoList(Name='DemoLoadBalancer') load_balancer_info = LoadBalancerInfo(ElbInfoList=[elb_info_list]) deployment_group = DeploymentGroup( "DemoDeploymentGroup", ApplicationName='DemoApplication', AutoRollbackConfiguration=auto_rollback_configuration, DeploymentStyle=deployment_style, LoadBalancerInfo=load_balancer_info, ServiceRoleArn='arn:aws:iam::0123456789:role/codedeploy-role') template.add_resource(deployment_group) # On premises deployment_group_on_premises = DeploymentGroup( "DemoDeploymentGroupOnPremises", DeploymentGroupName='DemoApplicationOnPremises', ApplicationName='DemoApplicationOnPremises', AutoRollbackConfiguration=auto_rollback_configuration, DeploymentStyle=DeploymentStyle( DeploymentOption='WITHOUT_TRAFFIC_CONTROL'), ServiceRoleArn='arn:aws:iam::0123456789:role/codedeploy-role', OnPremisesInstanceTagFilters=[
"autoscaling:DescribeLifecycleHooks", "autoscaling:DescribeAutoScalingGroups", "autoscaling:PutLifecycleHook", "autoscaling:RecordLifecycleActionHeartbeat" ] }, ], [Ref(role_code_deploy_trust_role)]) app = template.add_resource(Application('gcdtTenkaiTestingApp')) # CreateDeploymentGroup using applicationName as input and deploymentConfigName depgroup = template.add_resource( DeploymentGroup("gcdtTestDeploymentGroup", ApplicationName=Ref(app), ServiceRoleArn=GetAtt(role_code_deploy_trust_role, "Arn"), Ec2TagFilters=[ Ec2TagFilters(Key='Name', Value=NAME_TAG, Type='KEY_AND_VALUE') ])) template.add_output([ Output( "InstanceName", Description="InstanceId of the newly created EC2 instance", Value=NAME_TAG, ), Output( "InstanceId", Description="InstanceId of the newly created EC2 instance", Value=Ref(ec2_instance), ),