Repository navigation
Description
Description:
In v0.2.11 when running with sam local start-api, !Ref AWS::StackName returned 'goformation-stack' - I believe defined in https://github.com/awslabs/aws-sam-cli/blob/release/v0.2.11/vendor/github.com/awslabs/goformation/intrinsics/ref.go. In v0.3.0, it seems like nothing is returned.
Are these intrinsics still present in v0.3.0?
Steps to reproduce the issue:
- Create a template that references AWS::StackName (see template.yaml below)
- Create a app.js (see below) which logs
process.env.STACK_NAME - Run
sam local start-api - Navigate to http://localhost:3000/hello
template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sam-app
Sample SAM Template for sam-app
# 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:
Handler: app.lambda_handler
Runtime: nodejs8.10
Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
Variables:
STACK_NAME: !Ref AWS::StackName
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
app.js
exports.lambda_handler = async (event, context, callback) => {
console.log('stack name: ' + process.env.STACK_NAME);
callback(null, {
'statusCode': 200,
'body': 'OK'
});
};
Observed result:
v0.2.11: log contains stack name: goformation-stack
v0.3.0: log contains stack name:
Expected result:
Both versions should output a stack name.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Output of sam --version:
SAM CLI, version 0.3.0
Optional Debug logs:
Add --debug flag to command you are running
Activity
sanathkr commentedon Jun 29, 2018
Yes, this is a breaking change between the two versions. After v0.3.0 we stopped faking default AWS parameter values. Instead you can directly override the environment variable by passing value to
sam local start-api --env-varscommand.Would this work for you?
studds commentedon Jul 11, 2018
Yes, this will work in my case.
jfuss commentedon Jun 15, 2019
We started resolving
AWS::StackNamein v0.6.1. Locally the StackName is defined as 'local'.Closing