template = self.template variables = self.get_variables() dbsubnetgroup = template.add_resource( rds.DBSubnetGroup( 'DBSubnetGroup', SubnetIds=variables['PriSubnets'].ref, DBSubnetGroupDescription='RDS SubnetGroup', Tags=Tags(Name=Join( '-', ['RDSSubnet', Ref('EnvironmentName')]), ))) template.add_output( Output(dbsubnetgroup.title, Description='Physical ID of the DB Subnet Group', Value=Ref(dbsubnetgroup))) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description("Sturdy Platform - RDS Subnet Group " "- {0}".format(version.version())) self.add_resources() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == '__main__': from stacker.context import Context standalone_output.json( blueprint=RdsSubnet('test', Context({'namespace': 'test'}), None))
) ) template.add_output( Output( "{}Name".format(autoscalinggroup.title), Description="Name of the Auto Scaling Group", Value=Ref(autoscalinggroup) ) ) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description( 'Creates an Auto Scaling Group' ) self.add_resources_and_outputs() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( blueprint=AutoScalingGroup( 'test', Context({"namespace": "test"}), None ) )
settings['IpProtocol'] = 'tcp' template.add_resource( ec2.SecurityGroupIngress( 'SgIngress{}'.format(sub('[/.-]', '', rule)), GroupId=GetAtt(ec2securitygroup, 'GroupId'), **settings)) template.add_output( Output('{}Id'.format(ec2securitygroup.title), Description='ID of the Security Group created', Value=GetAtt(ec2securitygroup, 'GroupId'), Export=Export( Sub('${AWS::StackName}-%sId' % ec2securitygroup.title)))) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description( 'Creates an EC2 Security Group and its ingress rules') self.add_resources_and_output() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json(blueprint=SecurityGroupAndRules( 'test', Context({"namespace": "test"}), None))
ec2.EIPAssociation( 'Ec2EipSecondaryAssociation{}'.format(i+1), AllocationId=GetAtt(secondaryeip, 'AllocationId'), NetworkInterfaceId=Ref(ec2networkinterface), PrivateIpAddress=Select(i, GetAtt( ec2networkinterface, 'SecondaryPrivateIpAddresses') ) ) ) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description( 'Creates an EC2 Network Interface and optionally associates EIP(s)' ' to the private IP(s) and then attaches it to an EC2 Instance' ) self.add_resources_and_outputs() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( blueprint=NetworkInterfaceAndEip( 'test', Context({"namespace": "test"}), None ) )
Export=Export(Sub('${AWS::StackName}-%s' % cidringress.title)), # nopep8 pylint: disable=C0301 Value=Ref(cidringress), Condition='UseCidrIp')) template.add_output( Output( securitygroupingress.title, Description='Security group ingres rule for client', Export=Export( Sub('${AWS::StackName}-%s' % securitygroupingress.title)), # nopep8 pylint: disable=C0301 Value=Ref(securitygroupingress), Condition='UseSourceSecurityGroupId')) def create_template(self): """ Boilerplate for CFN Template """ self.template.add_version('2010-09-09') self.template.add_description( 'Create Ingress rules for Security Groups - 1.0.0') # nopep8 pylint: disable=C0301 self.add_conditions() self.create_security_groups_ingress() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json(blueprint=SecurityGroupsIngress( 'test', Context({"namespace": "test"}), # nopep8 pylint: disable=C0301 None))
Statement( Sid='DenyUnEncryptedObjectUploads', Action=[awacs.s3.PutObject], Condition=Condition( Null('s3:x-amz-server-side-encryption', 'true')), Effect=Deny, Principal=Principal('*'), Resource=[ Join('', [GetAtt(chefdatabucket, 'Arn'), '/*']) ]) ]))) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description('Onica Platform - Core' ' - Chef/Artifact Buckets - {}'.format( version.version())) self.add_conditions() self.add_resources() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( blueprint=ChefBuckets('test', Context({"namespace": "test"}), None))
LogGroupName=loggroup, RetentionInDays=variables['LogRetentionDays'].ref)) template.add_output( Output('{}Arn'.format(logsloggroup.title), Description='CloudWatch Logs log group ARN', Value=GetAtt(logsloggroup, 'Arn'), Export=Export( Sub('${AWS::StackName}-%sArn' % logsloggroup.title)))) template.add_output( Output('{}Name'.format(logsloggroup.title), Description='CloudWatch Logs log group name', Value=Ref(logsloggroup))) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description('Creates a CloudWatch Logs log group') self.add_resources_and_outputs() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( blueprint=LogGroups('test', Context({"namespace": "test"}), None))
variables['ChefClientRunCommand'].ref ], 'timeoutSeconds': '{{ executionTimeout }}', } }] }, DocumentType='Command')) template.add_output( Output( 'LinuxDocumentName', Description='Chef-client run SSM document for Linux', Value=Ref(linuxdocument), )) def create_template(self): """Entrypoint for Stacker.""" self.add_resources() self.template.add_description( 'Onica Platform - Core' ' - SSM chef-client Run Documents - {}'.format(version.version())) # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( SSMChefRunDocuments('test', Context({'namespace': 'test'}), None))
AlarmName=variables['AlarmName'].ref, ComparisonOperator='GreaterThanThreshold', Dimensions=[ cloudwatch.MetricDimension( Name='InstanceId', Value=variables['InstanceId'].ref) ], EvaluationPeriods=15, MetricName='EC2_SystemStatusCheck_Failed', Namespace='AWS/EC2', Period=60, Statistic='Minimum', Threshold='0', )) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description( 'Creates an AWS CloudWatch alarm to auto-recover an EC2 Instance' ' when it has status check failures for 15 consecutive minutes') self.add_resource() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( blueprint=Ec2Recover('test', Context({"namespace": "test"}), None))
'Topic' ) ) template.add_output( Output( "%sARN" % pagerdutyalert.title, Description='SNS topic', Value=Ref(pagerdutyalert) ) ) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description( 'Onica Platform - Core' ' - SNS Topic - {}'.format(version.version()) ) self.add_resources() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json(SnsTopic('test', Context({"namespace": "test"}), None))
'AccessPolicy', Description='Policy allowing use of the AMI lookup lambda ' 'function', Export=Export( Sub('${AWS::StackName}-%s' % 'AccessPolicy') ), Value=Ref(amilookupaccesspolicy) ) ) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description( 'Onica Platform - Core' ' - AMI Lookup - {}'.format(version.version()) ) self.add_resources_and_outputs() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( blueprint=AmiLookup('test', Context({"namespace": "test"}), None) )
def add_resources(self): """Add resources to template.""" template = self.template variables = self.get_variables() for repo in variables['RepoNames']: ecrrepo = template.add_resource( ecr.Repository('{}Repo'.format(sub('-', '', repo)), RepositoryName=repo)) template.add_output( Output(ecrrepo.title, Description='ECR repo ({})'.format(ecrrepo.title), Value=Ref(ecrrepo))) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description( 'Creates an Amazon Elastic Container Registry (Amazon ECR)' ' repository.') self.add_resources() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( blueprint=Repository('test', Context({"namespace": "test"}), None))
} } def add_resources(self): """Add resources to template.""" template = self.template variables = self.get_variables() template.add_resource( sns.SubscriptionResource('Subscription', Protocol=variables['Protocol'].ref, Endpoint=variables['Endpoint'].ref, TopicArn=variables['TopicARN'].ref)) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description("Sturdy Platform - Core - SNS " "Subscription " "- {0}".format(version.version())) self.add_resources() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( SnsSubscription('test', Context({"namespace": "test"}), None))
#], )) template.add_output( Output("{}Arn".format(ecstaskdefinition.title), Description="ARN of the Task Definition", Value=Ref(ecstaskdefinition), Export=Export( Sub('${AWS::StackName}-%sArn' % ecstaskdefinition.title)))) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description( 'Describes the container and volume definitions of an Amazon' ' Elastic Container Service (Amazon ECS) task. Specifies which' ' Docker images to use, the required resources and other' ' configurations related to launching the task definition through' ' an Amazon ECS service or task.') self.add_resources() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( blueprint=TaskDefinition('test', Context({"namespace": "test"}), None))
) template.add_output( Output( '{}PublicIp'.format(ec2instance.title), Description='The public IP of the instance', Value=GetAtt(ec2instance, 'PublicIp'), Export=Export(Sub('${AWS::StackName}-%sPublicIp' % ec2instance.title)) ) ) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description( 'Creates an EC2 Security Group' ) self.add_resource_and_output() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( blueprint=Instance( 'test', Context({"namespace": "test"}), None ) )
def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description( "Associates an IAM (inline) policy with IAM users, roles, or groups. " ) self.add_resources() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context if len(sys.argv) > 1: class_name = sys.argv[1].lower() else: class_name = 'all' if class_name == 'role' or class_name == 'all': print "\n--- Role [Begin] ---" standalone_output.json( blueprint=Role('test', Context({"namespace": "test"}), None)) print "--- Role [End] ---" if class_name == 'policy' or class_name == 'all': print "\n--- Policy [Begin] ---" standalone_output.json( blueprint=Policy('test', Context({"namespace": "test"}), None)) print "--- Policy [End] ---"
Priority=variables['Priority'].ref ) ) template.add_output(Output( "{}Arn".format(listenerrule.title), Description="ARN of the Listener Rule", Value=Ref(listenerrule), Export=Export( Sub('${AWS::StackName}-%sArn' % listenerrule.title) ) )) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description( "Sentient Science - Digital Clone Live - ALB Listener Rule" ) self.add_resources() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( blueprint=ListenerRule('test', Context({"namespace": "test"}), None) )
'policy/service-role/AmazonECSTaskExecutionRolePolicy' ] ) ) template.add_output( Output( "{}Arn".format(ecstaskexeciamrole.title), Description="ECS Task Execution IAM Role ARN", Value=GetAtt(ecstaskexeciamrole, "Arn"), ) ) def create_template(self): """Create template (main function called by Stacker).""" self.template.add_version('2010-09-09') self.template.add_description( "ECS Task Execution IAM Role" ) self.add_resources() # Helper section to enable easy blueprint -> template generation # (just run `python <thisfile>` to output the json) if __name__ == "__main__": from stacker.context import Context standalone_output.json( blueprint=EcsTaskExecRole('test', Context({"namespace": "test"}), None) )