LoginSignup
1
1

More than 5 years have passed since last update.

CloudFormation"Value of property SourceArn must be of type String"の解決方法

Posted at

AWS LambdaFunctionPermissionの設定で、以下のようなエラーが発生した。

Value of property SourceArn must be of type String
このとき、原因となった部分は以下の通り。

problem.yml
  LambdaPermission:
    Type: AWS::Lambda::Permission
    Properties:
      FunctionName:
        !GetAtt MyLambda.Arn
      Action: lambda:InvokeFunction
      Principal: s3.amazonaws.com
      SourceArn:
        - !Join
          - ''
          - - 'arn:aws:s3:::'
            - !Sub ${BucketPrefix}

原因と対策

- !Joinは、!Join以下がリスト型であることを示している。つまり、このymlは以下のように認識されている。

SourceArn.json
{
    ....,
    "Properties":{
        "SourceArn":['arn:aws:s3:::{BucketPrefix}']
    },
    ....
}

しかし、この項目に入力すべきはStringであり、Listではない。これがエラーの原因だったようだ。

したがって、以下のように直した。

fixed.yml
  DataDeliverAndConvertPermission:
    Type: AWS::Lambda::Permission
    Properties:
      FunctionName:
        !GetAtt MyLambda.Arn
      Action: lambda:InvokeFunction
      Principal: s3.amazonaws.com
      SourceArn:
        !Join
          - ''
          - - 'arn:aws:s3:::'
            - !Sub ${BucketPrefix}

これで通った。

参考

YAML 基本記法まとめ

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1