Failed to deploy SAM application with reason of Template error: instance of Fn::GetAtt references undefined resource HelloWorldFunctionRole
See original GitHub issueDesktop (please complete the following information):
- OS: Window 10
- VS Code version: 1.49.0(User setup)
- AWS Toolkit extension version: AWS 1.13.0
Question
I want to deploy my HelloWorldFunction template(Generate by Hello World basic app) , I done the following:
- Ctrl + Shift + P
- AWS: Deploy SAM aplication
- choose template.yaml
- Select region
- Enter name for S3 bucket created
- Enter name of stack
Then I get this error when deploy:
Error: Error with child process: Error: Failed to create changeset for the stack: my-stack, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED.
Reason: Template error: instance of Fn::GetAtt references undefined resource HelloWorldFunctionRole
Deploy failed
It said undefined resource for HelloWorldFunctionRole. But I already stated the Role Arn in my HelloWorldFunction.
Here is my template.yaml:
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
MyLambda
Sample SAM Template for MyLambda
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.8
Role: HERE I set the role arn that I created in AWS console ** Here is what I add
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /hello
Method: get
Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
HelloWorldApi:
Description: "API Gateway endpoint URL for Prod stage for Hello World function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
HelloWorldFunction:
Description: "Hello World Lambda Function ARN"
Value: !GetAtt HelloWorldFunction.Arn
HelloWorldFunctionIamRole:
Description: "Implicit IAM Role created for Hello World function"
Value: !GetAtt HelloWorldFunctionRole.Arn
All the above code is generated by AWS SAM Hello World template, I just add the Role Arn value in the field under Runtime as u see above…
What I have done:
- Created a role in AWS IAM Management Console.
- Attach policy as LambdaBasicExecutionPolicy for the role
- Copy Role Arn value to template.yaml as shown above
Then when deploy, I get the error as mention above.
Please give some guidance, don’t know what I missing out so far.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Template error: instance of Fn::GetAtt references undefined ...
I think you have to add the logical name of resource. Replace EventHandlerLambdaFunction to actual resource name eventHandler .
Read more >Template error: instance of Fn::GetAtt references undefined ...
I am trying to deploy a service to AWS using serverless framework and keep getting the following error: Error: The CloudFormation template ......
Read more >does not support attribute type arn in fn::getatt
Reason : Template error: instance of Fn::GetAtt references undefined resource HelloWorldFunctionRole ↓Layer Waiting for changeset to be created.. Error: Failed ...
Read more >AWS SAM: Tutorial - Anto Online
A Liberal set of permissions to apply and deploy changes. For example, the AWS SAM CLI makes calls to Amazon S3 and AWS...
Read more >Category: Amazon Web Services | itonaut.com
Simply deploy the following template via the AWS CloudFormation console. In the designer the template looks like this: Kinesis Data Stream ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @kenchoong
Could you try deleting the
HelloWorldFunctionIamRolefrom theOutputsection? SAM autogenerates a role, I believe using those parameters. Removing this should let you manually set a role.hey @bryceitoc9 ,thanks for the guidance.
It works now after delete
HelloWorldFunctionIamRolefromOutput.Thank you very much