Exemplo n.º 1
0
    def build_template(self, app_name, stage_name, bucket, zip_name,
                       stage_settings):
        sam = sm.SAM(Description=self.config.get('description'),
                     render_type='yaml')

        sam.add_parameter(sm.Parameter(name='Bucket', Type='String'))

        sam.add_parameter(sm.Parameter(name='CodeZipKey', Type='String'))

        app_stage = self.get_zip_name(app_name, stage_name, no_ext=True)

        sam.add_resource(
            sm.Function(name=app_name,
                        CodeUri=sm.S3URI(Bucket=sm.Ref(Ref='Bucket'),
                                         Key=sm.Ref(Ref='CodeZipKey')),
                        Handler='{app_name}.app.app'.format(app_name=app_name),
                        Runtime='python3.6',
                        Environment=sm.Environment(Variables=self.get_env_vars(
                            app_name, stage_name, stage_settings)),
                        Events=[
                            sm.APIEvent(name=app_name,
                                        Path='{proxy+}',
                                        Method='get')
                        ]))
        try:
            sam.publish(app_name, Bucket=bucket, CodeZipKey=zip_name)
        except ChangeEmptyError:
            print('New Zip uploaded, CloudFormation template unchanged,')
Exemplo n.º 2
0
import sammy as sm

sam = sm.SAM(
    Description='Alexa Skill https://developer.amazon.com/alexa-skills-kit')

sam.add_resource(
    sm.Function(name='AlexaSkillFunction',
                CodeUri=sm.S3URI(Bucket='<bucket>', Key='sammytest.zip'),
                Handler='sample.handler',
                Runtime='python3.6',
                Events=[sm.AlexaSkillEvent(name='AlexaSkillEvent')]))
Exemplo n.º 3
0
                           "Service": ["lambda.amazonaws.com"]
                       },
                       "Action": ["sts:AssumeRole"]
                   }]
               },
               ManagedPolicyArns=[
                   'arn:aws:iam::aws:policy/AmazonSQSFullAccess',
                   'arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess',
                   'arn:aws:iam::aws:policy/CloudWatchLogsFullAccess'
               ],
               RoleName='loadlamb')

f = sm.Function(
    name='loadlambpush',
    FunctionName='loadlamb-push',
    CodeUri=sm.S3URI(Bucket=sm.Ref(Ref='CodeBucket'),
                     Key=sm.Ref(Ref='CodeZipKey')),
    Handler='loadlamb.lambdas.push_handler',
    Runtime='python3.6',
    Timeout=300,
    Role=sm.Sub(Sub='arn:aws:iam::${AWS::AccountId}:role/loadlamb'),
    Environment=env)

f2 = sm.Function(
    name='loadlambpull',
    FunctionName='loadlamb-pull',
    CodeUri=sm.S3URI(Bucket=sm.Ref(Ref='CodeBucket'),
                     Key=sm.Ref(Ref='CodeZipKey')),
    Handler='loadlamb.lambdas.pull_handler',
    Runtime='python3.6',
    Timeout=300,
    MemorySize=3008,