내용으로 건너뛰기

AWS SAM, unable to dynamically change the CodeUri based on Variable

0

I have different local directories for three different environments with differnet codes. I can map all other properties dynamically except the codeUri. The current code below shows up an error "'CodeUri' requires Bucket and Key properties to be specified."

  AuditEventsToDynamo:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: !Sub 'AuditEventsToDynamo${ENV}'
      CodeUri: !Sub 'AuditEventsToDynamo${ENV}/'
      Handler: !Join [ "", ["AuditEventsToDynamo" ,!Ref "ENV",".lambda_handler"]]
      Runtime: python3.9
      Environment:
        Variables:
          DB_TABLE: !Ref DBTABLE
      Architectures:
        - arm64

The code is local, if I replace the CodeUri with a literal string, it works. Is there a workaround?

질문됨 3년 전504회 조회
1개 답변
0

What's the "literal string" you used that works, and what's the value of "ENV" when it fails? If ENV is something like "Dev", "Prod" etc then the error makes sense - your CodeUri wouldn't have both a Bucket and Key specified.

전문가
답변함 3년 전
  • I have three local directories named as AuditEventsToDynamoProd AuditEventsToDynamoTest . If I give the path as "AuditEventsToDynamoProd", it works. I couldn't use any Intrinsic Functions to add dynamic values.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠