コード例 #1
0
def update_stack(name, template, params):
    cf = boto3.client("cloudformation")
    wait_for_stack(cf, name)
    print("Updating stack '{}'".format(name))
    cf.update_stack(StackName=name,
                    TemplateBody=json.dumps(template),
                    Parameters=[{
                        "ParameterKey": k,
                        "ParameterValue": params[k]
                    } for k in params],
                    Capabilities=['CAPABILITY_IAM'])
    return wait_for_stack(cf, name)
コード例 #2
0
def create_stack(cluster_name, template, params, **kwargs):
    cf = boto3.client("cloudformation")
    try:
        logging.debug("Creating stack '{}'".format(cluster_name))
        cf.create_stack(StackName=cluster_name,
                        TemplateBody=json.dumps(template),
                        Parameters=[{
                            "ParameterKey": k,
                            "ParameterValue": params[k]
                        } for k in params if params[k]],
                        Capabilities=['CAPABILITY_IAM'],
                        OnFailure='ROLLBACK')
    except Exception as e:
        logging.warn(traceback.format_exc())
        pass
    return wait_for_stack(cluster_name)
コード例 #3
0
def create_stack(name, template, params):
    cf = boto3.client("cloudformation")
    try:
        print("Creating stack '{}'".format(name))
        cf.create_stack(StackName=name,
                        TemplateBody=json.dumps(template),
                        Parameters=[{
                            "ParameterKey": k,
                            "ParameterValue": params[k]
                        } for k in params],
                        Capabilities=['CAPABILITY_IAM'],
                        OnFailure='ROLLBACK')
    except Exception as e:
        traceback.print_exc()
        pass
    return wait_for_stack(cf, name)
コード例 #4
0
def update_stack(cluster_name, template, params, **kwargs):
    cf = boto3.client("cloudformation")
    try:
        logging.debug("Updating stack '{}'".format(cluster_name))
        cf.update_stack(StackName=cluster_name,
                        TemplateBody=json.dumps(template),
                        Parameters=[{
                            "ParameterKey": k,
                            "ParameterValue": params[k]
                        } for k in params if params[k]],
                        Capabilities=['CAPABILITY_IAM'])
    except Exception as e:
        logging.warn(traceback.format_exc())
        if 'No updates are to be performed' in str(e):
            pass
        else:
            raise e
    return wait_for_stack(cluster_name)
コード例 #5
0
def lambda_handler(event, context):
    return make_response(body="<pre>\n{}\n</pre>".format(
        json.dumps(event, indent=2, sort_keys=True)))
コード例 #6
0
 def describe_cluster(self, *args, **kwargs):
     print(
         json.dumps(wiglaf.cloudformation.get_stack_info(**self.config),
                    indent=4,
                    sort_keys=True))
コード例 #7
0
                    "Ref": "Function"
                },
                "Action": "lambda:InvokeFunction",
                "Principal": "s3.amazonaws.com",
                "SourceArn": {
                    "Fn::Sub": "arn:${AWS::Partition}:s3:::*"
                }
            }
        }
    },
    "Outputs": {
        "LambdaBucket": {
            "Value": {
                "Ref": "LambdaBucket"
            }
        },
        "DataBucket": {
            "Value": {
                "Ref": "DataBucket"
            }
        },
        "AutoScalingGroup": {
            "Value": {
                "Ref": "AutoScalingGroup"
            }
        }
    }
}

WIGLAF_TEMPLATE_BODY = json.dumps(WIGLAF_TEMPLATE, separators=(',', ':'))