How do I access CloudFormation stack name from the Macro Handler?

0

Hi, Can you please suggest a way to access the cloud formation stack name from the Macro lambda handler? I don't see the stack name getting passed in the event or context parameter of the handler function.

ssuk
질문됨 2년 전607회 조회
2개 답변
1

I don't see a way to do it, but here's an idea for a workaround that may help depending on how you invoke stack create/update. Add a "StackName" parameter to your template, and set it to the name of the stack when it's created. Template parameters like this get passed to the Lambda function.

전문가
답변함 2년 전
  • Thanks for your response. Yes, I managed to get it working using parameters and accessing the parameter in the handler using 'event.templateParameterValues.stack'. I was expecting a more direct way to get this value as CF is already aware of the stack name.

0

Not sure what your specific scenario is but I managed to resolve this in a Macro I created using the AWS::StackName pseudo parameter. So my Macro would add a resource with a value of { "Fn::Sub": "SomeValue-${AWS::StackName}" } and CloudFormation would resolve that to "SomeValue-MyStackName" after the Macro returns the updated template.

답변함 일 년 전

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

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

질문 답변하기에 대한 가이드라인

관련 콘텐츠