-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not use Fn::if within CustomStatements: #1218
Comments
@eerb-kyruus Thanks for reporting this. Looks like this code isn't taking intrinsic functions into account: For now, a possible workaround would be to embed the ResourcePolicy:
CustomStatements:
- !If
- IsProd
- Principal: '*'
Effect: Allow
Action: <redacted>
Resource: <redacted>
- !Ref AWS::NoValue
- !If
- IsProd
- Principal: '*'
Effect: Allow
Action: <redacted>
Resource: <redacted>
Condition:
<redacted>
- !Ref AWS::NoValue I'm not sure what CloudFormation will do in the case that all custom statements have this condition and the condition is false. Hopefully it will treat this as an empty list. However, it may throw an error due to all child values resolving to |
You might be able to get this to work by adding Transform:
- AWS::LanguageExtensions
- AWS::Serverless-2016-10-31
See #2533 for more information. |
Closing in favor of #2533. |
Description:
I am attempting to write a custom policy for my Serverless api that depends on deployment type. The serverless transform expects a list inside the CustomStatements: label, preventing use of fn:If to conditionally set policies. The obvious work-around is to specify the entire swagger document myself, but this creates lots of duplication and a huge template.
Steps to reproduce the issue:
NOTE: Confidential parts of the template have been redacted
Conditions:
IsProd:
Observed result:
The macro creates the following within the swagger doc, reformatted for readability. Note carefully the extra set of square brackets around the policy statement:
The deploy fails due to that extra set of square brackets in the policy statement
Expected result:
The swagger gateway policy is created with a single set of square brackets and the deploy succeeds.
The text was updated successfully, but these errors were encountered: