def create_stack(name, template_filename, bucket, context, timeout_in_minutes, **kwargs): """Creates a new CloudFormation stack with name ``name`` using as template ``template_filename`` and ``context`` as parameters.""" client = boto3.client('cloudformation') with open(template_filename, 'r') as f: template_body = f.read() extra = {} if bucket: extra['TemplateURL'] = upload_to_s3( bucket, get_template_s3_key(template_filename), template_body) else: extra['TemplateBody'] = template_body parameters = filter_context_for_template(context, template_body) stack = client.create_stack(StackName=name, Parameters=[{ 'ParameterKey': k, 'ParameterValue': v } for k, v in six.iteritems(parameters)], TimeoutInMinutes=timeout_in_minutes, Capabilities=['CAPABILITY_IAM'], OnFailure='DO_NOTHING', Tags=[{ 'Key': 'GordonVersion', 'Value': get_version() }], **extra) return get_cf_stack(stack['StackId'])
def create_stack(name, template_filename, bucket, context, timeout_in_minutes, **kwargs): """Creates a new CloudFormation stack with name ``name`` using as template ``template_filename`` and ``context`` as parameters.""" client = boto3.client('cloudformation') with open(template_filename, 'r') as f: template_body = f.read() extra = {} if bucket: extra['TemplateURL'] = upload_to_s3( bucket, get_template_s3_key(template_filename), template_body ) else: extra['TemplateBody'] = template_body parameters = filter_context_for_template(context, template_body) stack = client.create_stack( StackName=name, Parameters=[{'ParameterKey': k, 'ParameterValue': v} for k, v in six.iteritems(parameters)], TimeoutInMinutes=timeout_in_minutes, Capabilities=['CAPABILITY_IAM'], OnFailure='DO_NOTHING', Tags=[ { 'Key': 'GordonVersion', 'Value': get_version() } ], **extra ) return get_cf_stack(stack['StackId'])