0

Cloudbox를 사용하여 ObjectCreate에있는 Lambda 함수를 호출하는 S3 버킷을 배포하려고합니다. 여기 Cloud Formation : S3가 Lambda에 연결하면 ARN이 제대로 형성되지 않습니다.

내 자원입니다 : 내가 순환 종속성이있을 수 있다고 말한다 알림 구성의 설명서를 따르도록 노력했습니다

"ExampleFunction": { 
 
      "Type": "AWS::Lambda::Function", 
 
      "Properties": { 
 
       "Handler": "index.lambda_handler", 
 
       "Code": { 
 
        "S3Bucket": "bucketname", 
 
        "S3Key": "something.zip" 
 
       }, 
 
       "Runtime": "python3.6", 
 
       "Role": { 
 
        "Fn::GetAtt": [ 
 
         "LambdaExecutionRole", 
 
         "Arn" 
 
        ] 
 
       } 
 
      } 
 
     }, 
 
     "InputDataBucket": { 
 
      "Type": "AWS::S3::Bucket", 
 
      "Properties": { 
 
       "BucketName": "input-data", 
 
       "NotificationConfiguration": { 
 
        "LambdaConfigurations": [ 
 
         { 
 
          "Function": { 
 
           "Ref": "ExampleFunction" 
 
          }, 
 
          "Event": "s3:ObjectCreated:*", 
 
          "Filter": { 
 
           "S3Key": { 
 
            "Rules": [ 
 
             { 
 
              "Name": "suffix", 
 
              "Value": "zip" 
 
             } 
 
            ] 
 
           } 
 
          } 
 
         } 
 
        ] 
 
       } 
 
      } 
 
     }, 
 
     "LambdaInvokePermission": { 
 
      "Type": "AWS::Lambda::Permission", 
 
      "Properties": { 
 
       "Action": "lambda:InvokeFunction", 
 
       "FunctionName": { 
 
        "Fn::GetAtt": [ 
 
         "ExampleFunction", 
 
         "Arn" 
 
        ] 
 
       }, 
 
       "Principal": "s3.amazonaws.com", 
 
       "SourceAccount": { 
 
        "Ref": "AWS::AccountId" 
 
       }, 
 
       "SourceArn": { 
 
        "Fn::Join": [ 
 
         ":", 
 
         [ 
 
          "arn", 
 
          "aws", 
 
          "s3", 
 
          "", 
 
          "", 
 
          { 
 
           "Ref": "InputDataBucket" 
 
          } 
 
         ] 
 
        ] 
 
       } 
 
      } 
 
     }

. 그러나 지시 사항을 따르면 동일한 오류가 발생합니다. 참고 : 나는 스택을 만들려고 할 때 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfig.html

의 S3는 항상 오류를 나누기 "이 ARN이 잘 형성되지 않는다"

나는 많은 것들을 시도했습니다,하지만 난 항상이 같은 오류가 발생합니다.

+0

초기 CF 작성에서 S3 버킷 및 람다 함수 만 작성한 다음 NotificationConfiguration을 템플릿에 추가하고 마지막으로 CF 업데이트를 수행하고 있습니까? 또한 SourceArn 사용 권한을 얻으려면 "Fn :: GetAtt": [ "InputDataBucket", "Arn"]을 사용하십시오. – jarmod

+0

IAM 역할도 있지만 그 밖의 것은 없습니다. NotificationConf 제거한 다음 그것을 사용하여 업데이트 시도했지만 여전히 동일한 오류가 나타납니다. – Miika

답변

1

미리 S3 버킷 이름 (mybucketname 아래)을 알고있는 한이 기능을 사용할 수 있습니다. 버킷 이름을 미리 알지 못하면 버킷 이름을 스택 매개 변수로 요청하기 위해이를 향상시킬 수 있으며 여전히 작동해야합니다. 버킷 이름을 자동으로 생성해야하므로 (미리 이름을 예측할 수 없으므로) 작동하지 않으며 작성/업데이트 경로로 이동해야합니다.

여기서 중요한 것은 버킷 이름을 얻기 위해 "Ref": "InputDataBucket"에 의존하는 대신 알려진 버킷 이름에서 S3 버킷 ARN을 수동으로 생성하는 것입니다.

this support article도 읽을만한 가치가 있습니다.

{ 
    "AWSTemplateFormatVersion": "2010-09-09", 

    "Description": "stackoverflow-48037497", 

    "Resources" : { 
     "ExampleFunction": { 
      "Type": "AWS::Lambda::Function", 
      "Properties": { 
       "Handler": "index.lambda_handler", 
       "Code": { 
        "S3Bucket": "bucketname", 
        "S3Key": "something.zip" 
       }, 
       "Runtime": "python3.6", 
       "Role": { 
        "Fn::GetAtt": [ 
         "LambdaExecutionRole", 
         "Arn" 
        ] 
       } 
      } 
     }, 
     "LambdaInvokePermission": { 
      "Type": "AWS::Lambda::Permission", 
      "DependsOn": [ "ExampleFunction" ], 
      "Properties": { 
       "Action": "lambda:InvokeFunction", 
       "FunctionName": { 
        "Fn::GetAtt": [ 
         "ExampleFunction", 
         "Arn" 
        ] 
       }, 
       "Principal": "s3.amazonaws.com", 
       "SourceAccount": { 
        "Ref": "AWS::AccountId" 
       }, 
       "SourceArn": "arn:aws:s3:::mybucketname" 
      } 
     }, 
     "InputDataBucket": { 
      "Type": "AWS::S3::Bucket", 
      "DependsOn": [ "ExampleFunction", "LambdaInvokePermission" ], 
      "Properties": { 
       "BucketName": "mybucketname", 
       "NotificationConfiguration": { 
        "LambdaConfigurations": [ 
         { 
          "Function": { "Fn::GetAtt" : [ "ExampleFunction", "Arn" ] }, 
          "Event": "s3:ObjectCreated:*" 
         } 
        ] 
       } 
      } 
     } 
    } 
} 
관련 문제