Variables replacement does not work in nested templates
See original GitHub issueThis is a Bug Report
Description
For bug reports:
- What went wrong?
Variables replacement did not work in my resources file. This is not a problem in 1.12.1
Using the sls package
command the DynamoTable part of the cloudformation-template-update-stack.json
is :
"DynamoTable": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
"TableName": "${self:service}-${self:custom.stage}-myAttribute",
"AttributeDefinitions": [
{
"AttributeName": "myAttribute",
"AttributeType": "S"
}
],
"KeySchema": [
{
"AttributeName": "myAttribute",
"KeyType": "HASH"
}
],
"ProvisionedThroughput": {
"ReadCapacityUnits": 10,
"WriteCapacityUnits": 10
}
}
}
- What did you expect should have happened?
The DynamoTable part of cloudformation-template-update-stack.json
should be:
"DynamoTable": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
"TableName": "sls-variables-test-dev-myAttribute",
"AttributeDefinitions": [
{
"AttributeName": "myAttribute",
"AttributeType": "S"
}
],
"KeySchema": [
{
"AttributeName": "myAttribute",
"KeyType": "HASH"
}
],
"ProvisionedThroughput": {
"ReadCapacityUnits": 10,
"WriteCapacityUnits": 10
}
}
}
- What was the config you used?
Project Structure
.
├── handler.js
├── serverless.yml
└── slsConfig
└── aws-resources
├── dev.resources.yml
└── templates
└── dynamoDB.resources.yml
serverless.yml
service: sls-variables-test
custom:
stage: ${opt:stage, self:provider.stage}
provider:
name: aws
runtime: nodejs6.10
stage: dev
functions:
hello:
handler: handler.hello
resources:
Resources:
${file(slsConfig/aws-resources/${self:custom.stage}.resources.yml)}
slsConfig/aws-resources/dev.resources.yml
${file(slsConfig/aws-resources/templates/dynamoDB.resources.yml)}
slsConfig/aws-resources/templates/dynamoDB.resources.yml
DynamoTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: '${self:service}-${self:custom.stage}-myAttribute'
AttributeDefinitions:
- AttributeName: myAttribute
AttributeType: S
KeySchema:
- AttributeName: myAttribute
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 10
WriteCapacityUnits: 10
- What stacktrace or error message from your provider did you see?
..........Serverless: Deployment failed!
Serverless Error ---------------------------------------
An error occurred while provisioning your stack: DynamoTable
- 1 validation error detected: Value '${self:service}-${self:custom.stage}-myAttribute'
at 'tableName' failed to satisfy constraint: Member
must satisfy regular expression pattern: [a-zA-Z0-9_.-]+.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Forums: forum.serverless.com
Chat: gitter.im/serverless/serverless
Your Environment Information -----------------------------
OS: linux
Node Version: 6.10.2
Serverless Version: 1.13.0
Similar or dependent issues:
Additional Data
- Serverless Framework Version you’re using: 1.13.0
- Operating System: Gnome Ubuntu 16.04
- Stack Trace:
- Provider Error messages:
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Nested variable and resource with copy not working
I have defined "lbApiVersion" inside nested resource variable block but some how the nested variable block is not recognize. below is the ARM ......
Read more >Variables in templates - Azure Resource Manager
Describes how to define variables in an Azure Resource Manager template (ARM template).
Read more >Where variables can be used - GitLab Docs
- Variables from pipeline schedules. Not supported are variables defined in the GitLab Runner config.toml , variables defined in jobs, or Persisted variables....
Read more >The Django template language - Django documentation
The Django template system provides tags which function similarly to some ... If you use a variable that doesn't exist, the template system...
Read more >macro, nested, return - Apache FreeMarker Manual
The variable will be created at the beginning of the template; it does not mater where the macro directive is placed in the...
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
Fixed and working - Tested with 1.14.0
Thanks for confirming @NaraGitHub 👍