无效的模板资源属性“策略”

时间:2021-05-11 12:12:24

标签: aws-lambda amazon-cloudformation amazon-iam

你能帮忙解决这里的问题吗?

当我尝试运行以下云形成堆栈时出现错误。我正在尝试使用云格式创建具有 sns 角色的 lambda 函数 Invalid template resource property 'Policies'

  AWSTemplateFormatVersion: '2010-09-09'
    Description: VPC function.
    Resources:
      Function:
        Type: AWS::Lambda::Function
        Properties:
          Handler: index.handler
          Code:
            S3Bucket: teste-artifact-bucket
            S3Key: function.zip
          Runtime: python3.6
          Timeout: 5
          TracingConfig:
            Mode: Active
      LambdaExecutionRole:
        Description: Creating service role in IAM for AWS Lambda
        Type: AWS::IAM::Role
        Properties:
          RoleName:
            Fn::Sub: ${ProjectId}-execution
          AssumeRolePolicyDocument:
            Statement:
            - Effect: Allow
              Principal:
                Service:
                - lambda.amazonaws.com
              Action: sts:AssumeRole
          Path: /
        Policies:
          PolicyName: Lamda addtional access 
            PolicyDocument:
              Version: 2012-10-17
              Statement:
                - Effect: Allow
                  Action:
                  - sns:Subscribe
                  - sns:Publish
                  - sns:CreateTopic
                  - logs:PutLogEvents
                  - logs:CreateLogStream
                  - logs:CreateLogGroup
                  Resource: '*'
          ManagedPolicyArns:
            - !Sub 'arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole'
      LambdaFunctionLogGroup:
        Type: AWS::Logs::LogGroup
        Properties:
          LogGroupName: !Sub '/aws/lambda/${ProjectId}'
          RetentionInDays: 60

1 个答案:

答案 0 :(得分:1)

Policies 代码块缩进不够