-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
When a conditional resource has no metadata, update_policy, deletion_policy, or dependencies, the Python synthesizer generates an empty if block which is a syntax error.
It should either emit pass or skip the if block entirely when there are no attributes to emit.
Can be reproduced by any CloudFormation template with a conditional resource that has no Metadata, UpdatePolicy, DeletionPolicy, or DependsOn.
For example:
Input
AWSTemplateFormatVersion: "2010-09-09"
Conditions:
CreateResource:
!Equals [!Ref "AWS::Region", "us-east-1"]
Resources:
ConditionalBucket:
Type: AWS::S3::Bucket
Condition: CreateResource
Properties:
BucketName: test-bucket'Output
from aws_cdk import Stack
import aws_cdk as cdk
import aws_cdk.aws_s3 as s3
from constructs import Construct
class NoctStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
# Conditions
create_resource = self.region == 'us-east-1'
# Resources
conditionalBucket = s3.CfnBucket(self, 'ConditionalBucket',
bucket_name = 'test-bucket',
) if create_resource else None
if (conditionalBucket is not None):The file ends with if (conditionalBucket is not None):. Nothing after the if statement. Python requires at least pass inside an if block, otherwise it's a syntax error.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels