Can't return integer from Conditional function in cloud formation yaml
I am writing a cloudformation serverless yaml for a lambda function. I need a conditional parameter reservedConcurrency
to be 100 if IsProduction is true, 20 if false. But error happens when I deploy the yaml file:
You should use integer as reservedConcurrency value on function
resources:
Conditions:
IsProduction:
Fn::Equals:
- ${self:provider.stage}
- production
functions:
somefunction:
handler: functions/somefunction
timeout: 300
events:
- sqs:
arn:
Fn::GetAtt: [ somequeue, Arn ]
batchSize: 10
reservedConcurrency:
Fn::If:
- IsProduction
- 100
- 20
aws-lambda yaml amazon-cloudformation serverless-framework
|
show 1 more comment
I am writing a cloudformation serverless yaml for a lambda function. I need a conditional parameter reservedConcurrency
to be 100 if IsProduction is true, 20 if false. But error happens when I deploy the yaml file:
You should use integer as reservedConcurrency value on function
resources:
Conditions:
IsProduction:
Fn::Equals:
- ${self:provider.stage}
- production
functions:
somefunction:
handler: functions/somefunction
timeout: 300
events:
- sqs:
arn:
Fn::GetAtt: [ somequeue, Arn ]
batchSize: 10
reservedConcurrency:
Fn::If:
- IsProduction
- 100
- 20
aws-lambda yaml amazon-cloudformation serverless-framework
I know this is kinda dumb but did you try Fn::If: [IsProduction, 100, 20]?
– congbaoguier
Dec 28 '18 at 18:48
@congbaoguier Yep, tried it. same error.
– MikeJ
Dec 28 '18 at 18:56
Please provide the full and correct definition of your AWS Lambda function (e.g. your keys are currently wrong). Also adding the definition of theIsProduction
conditional would be helpful to provide a full example.
– Dunedan
Dec 28 '18 at 19:21
@Dunedan add theIsProduction
for reference. That part has been tested working in some other configuration, so, don't worry about it. Which key do you think is wrong?
– MikeJ
Dec 28 '18 at 19:36
E.g. upper/-lowercase of your keys is wrong. I suggest you use a tool like github.com/awslabs/cfn-python-lint to verify your template is valid.
– Dunedan
Dec 28 '18 at 20:16
|
show 1 more comment
I am writing a cloudformation serverless yaml for a lambda function. I need a conditional parameter reservedConcurrency
to be 100 if IsProduction is true, 20 if false. But error happens when I deploy the yaml file:
You should use integer as reservedConcurrency value on function
resources:
Conditions:
IsProduction:
Fn::Equals:
- ${self:provider.stage}
- production
functions:
somefunction:
handler: functions/somefunction
timeout: 300
events:
- sqs:
arn:
Fn::GetAtt: [ somequeue, Arn ]
batchSize: 10
reservedConcurrency:
Fn::If:
- IsProduction
- 100
- 20
aws-lambda yaml amazon-cloudformation serverless-framework
I am writing a cloudformation serverless yaml for a lambda function. I need a conditional parameter reservedConcurrency
to be 100 if IsProduction is true, 20 if false. But error happens when I deploy the yaml file:
You should use integer as reservedConcurrency value on function
resources:
Conditions:
IsProduction:
Fn::Equals:
- ${self:provider.stage}
- production
functions:
somefunction:
handler: functions/somefunction
timeout: 300
events:
- sqs:
arn:
Fn::GetAtt: [ somequeue, Arn ]
batchSize: 10
reservedConcurrency:
Fn::If:
- IsProduction
- 100
- 20
aws-lambda yaml amazon-cloudformation serverless-framework
aws-lambda yaml amazon-cloudformation serverless-framework
edited Dec 28 '18 at 22:19
John Rotenstein
68.9k777121
68.9k777121
asked Dec 28 '18 at 17:53
MikeJMikeJ
134
134
I know this is kinda dumb but did you try Fn::If: [IsProduction, 100, 20]?
– congbaoguier
Dec 28 '18 at 18:48
@congbaoguier Yep, tried it. same error.
– MikeJ
Dec 28 '18 at 18:56
Please provide the full and correct definition of your AWS Lambda function (e.g. your keys are currently wrong). Also adding the definition of theIsProduction
conditional would be helpful to provide a full example.
– Dunedan
Dec 28 '18 at 19:21
@Dunedan add theIsProduction
for reference. That part has been tested working in some other configuration, so, don't worry about it. Which key do you think is wrong?
– MikeJ
Dec 28 '18 at 19:36
E.g. upper/-lowercase of your keys is wrong. I suggest you use a tool like github.com/awslabs/cfn-python-lint to verify your template is valid.
– Dunedan
Dec 28 '18 at 20:16
|
show 1 more comment
I know this is kinda dumb but did you try Fn::If: [IsProduction, 100, 20]?
– congbaoguier
Dec 28 '18 at 18:48
@congbaoguier Yep, tried it. same error.
– MikeJ
Dec 28 '18 at 18:56
Please provide the full and correct definition of your AWS Lambda function (e.g. your keys are currently wrong). Also adding the definition of theIsProduction
conditional would be helpful to provide a full example.
– Dunedan
Dec 28 '18 at 19:21
@Dunedan add theIsProduction
for reference. That part has been tested working in some other configuration, so, don't worry about it. Which key do you think is wrong?
– MikeJ
Dec 28 '18 at 19:36
E.g. upper/-lowercase of your keys is wrong. I suggest you use a tool like github.com/awslabs/cfn-python-lint to verify your template is valid.
– Dunedan
Dec 28 '18 at 20:16
I know this is kinda dumb but did you try Fn::If: [IsProduction, 100, 20]?
– congbaoguier
Dec 28 '18 at 18:48
I know this is kinda dumb but did you try Fn::If: [IsProduction, 100, 20]?
– congbaoguier
Dec 28 '18 at 18:48
@congbaoguier Yep, tried it. same error.
– MikeJ
Dec 28 '18 at 18:56
@congbaoguier Yep, tried it. same error.
– MikeJ
Dec 28 '18 at 18:56
Please provide the full and correct definition of your AWS Lambda function (e.g. your keys are currently wrong). Also adding the definition of the
IsProduction
conditional would be helpful to provide a full example.– Dunedan
Dec 28 '18 at 19:21
Please provide the full and correct definition of your AWS Lambda function (e.g. your keys are currently wrong). Also adding the definition of the
IsProduction
conditional would be helpful to provide a full example.– Dunedan
Dec 28 '18 at 19:21
@Dunedan add the
IsProduction
for reference. That part has been tested working in some other configuration, so, don't worry about it. Which key do you think is wrong?– MikeJ
Dec 28 '18 at 19:36
@Dunedan add the
IsProduction
for reference. That part has been tested working in some other configuration, so, don't worry about it. Which key do you think is wrong?– MikeJ
Dec 28 '18 at 19:36
E.g. upper/-lowercase of your keys is wrong. I suggest you use a tool like github.com/awslabs/cfn-python-lint to verify your template is valid.
– Dunedan
Dec 28 '18 at 20:16
E.g. upper/-lowercase of your keys is wrong. I suggest you use a tool like github.com/awslabs/cfn-python-lint to verify your template is valid.
– Dunedan
Dec 28 '18 at 20:16
|
show 1 more comment
1 Answer
1
active
oldest
votes
You can't use Cloudformation intrinsic functions within the functions
block inside the serverless.yml
file.
Instead try using nested variables
custom:
concurrency:
prod: 100
functions:
somefunction:
handler: functions/somefunction
timeout: 300
events:
- sqs:
arn:
Fn::GetAtt: [ somequeue, Arn ]
batchSize: 10
reservedConcurrency: ${self:custom.concurrency.${self:provider.stage}, 20}
Thank you for the solution. It works perfectly.
– MikeJ
Jan 7 at 15:41
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53962442%2fcant-return-integer-from-conditional-function-in-cloud-formation-yaml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can't use Cloudformation intrinsic functions within the functions
block inside the serverless.yml
file.
Instead try using nested variables
custom:
concurrency:
prod: 100
functions:
somefunction:
handler: functions/somefunction
timeout: 300
events:
- sqs:
arn:
Fn::GetAtt: [ somequeue, Arn ]
batchSize: 10
reservedConcurrency: ${self:custom.concurrency.${self:provider.stage}, 20}
Thank you for the solution. It works perfectly.
– MikeJ
Jan 7 at 15:41
add a comment |
You can't use Cloudformation intrinsic functions within the functions
block inside the serverless.yml
file.
Instead try using nested variables
custom:
concurrency:
prod: 100
functions:
somefunction:
handler: functions/somefunction
timeout: 300
events:
- sqs:
arn:
Fn::GetAtt: [ somequeue, Arn ]
batchSize: 10
reservedConcurrency: ${self:custom.concurrency.${self:provider.stage}, 20}
Thank you for the solution. It works perfectly.
– MikeJ
Jan 7 at 15:41
add a comment |
You can't use Cloudformation intrinsic functions within the functions
block inside the serverless.yml
file.
Instead try using nested variables
custom:
concurrency:
prod: 100
functions:
somefunction:
handler: functions/somefunction
timeout: 300
events:
- sqs:
arn:
Fn::GetAtt: [ somequeue, Arn ]
batchSize: 10
reservedConcurrency: ${self:custom.concurrency.${self:provider.stage}, 20}
You can't use Cloudformation intrinsic functions within the functions
block inside the serverless.yml
file.
Instead try using nested variables
custom:
concurrency:
prod: 100
functions:
somefunction:
handler: functions/somefunction
timeout: 300
events:
- sqs:
arn:
Fn::GetAtt: [ somequeue, Arn ]
batchSize: 10
reservedConcurrency: ${self:custom.concurrency.${self:provider.stage}, 20}
edited Jan 6 at 20:34
answered Jan 6 at 20:27
tkwargstkwargs
1,1621923
1,1621923
Thank you for the solution. It works perfectly.
– MikeJ
Jan 7 at 15:41
add a comment |
Thank you for the solution. It works perfectly.
– MikeJ
Jan 7 at 15:41
Thank you for the solution. It works perfectly.
– MikeJ
Jan 7 at 15:41
Thank you for the solution. It works perfectly.
– MikeJ
Jan 7 at 15:41
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53962442%2fcant-return-integer-from-conditional-function-in-cloud-formation-yaml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I know this is kinda dumb but did you try Fn::If: [IsProduction, 100, 20]?
– congbaoguier
Dec 28 '18 at 18:48
@congbaoguier Yep, tried it. same error.
– MikeJ
Dec 28 '18 at 18:56
Please provide the full and correct definition of your AWS Lambda function (e.g. your keys are currently wrong). Also adding the definition of the
IsProduction
conditional would be helpful to provide a full example.– Dunedan
Dec 28 '18 at 19:21
@Dunedan add the
IsProduction
for reference. That part has been tested working in some other configuration, so, don't worry about it. Which key do you think is wrong?– MikeJ
Dec 28 '18 at 19:36
E.g. upper/-lowercase of your keys is wrong. I suggest you use a tool like github.com/awslabs/cfn-python-lint to verify your template is valid.
– Dunedan
Dec 28 '18 at 20:16