From 77c89e1ffe4baf6be8da21f722cbc39984c46d47 Mon Sep 17 00:00:00 2001 From: Ben Bridts Date: Fri, 31 Aug 2018 12:12:28 +0200 Subject: [PATCH 1/4] Return real booleans in the output --- troposphere/validators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/troposphere/validators.py b/troposphere/validators.py index e34c54374..cc56848ff 100644 --- a/troposphere/validators.py +++ b/troposphere/validators.py @@ -9,9 +9,9 @@ def boolean(x): if x in [True, 1, '1', 'true', 'True']: - return "true" + return True if x in [False, 0, '0', 'false', 'False']: - return "false" + return False raise ValueError From 020cb83c683106a7a37f95c8eef814c229a4521e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ufl?= Date: Wed, 10 Jul 2019 17:48:23 +0200 Subject: [PATCH 2/4] Use real booleans in the output only if env var is set --- troposphere/validators.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/troposphere/validators.py b/troposphere/validators.py index cc56848ff..dd82f2251 100644 --- a/troposphere/validators.py +++ b/troposphere/validators.py @@ -4,15 +4,24 @@ # See LICENSE file for full license. import json +import os from re import compile -def boolean(x): - if x in [True, 1, '1', 'true', 'True']: - return True - if x in [False, 0, '0', 'false', 'False']: - return False - raise ValueError +if os.getenv("TROPO_REAL_BOOL") in ['1', 'true', 'True']: + def boolean(x): + if x in [True, 1, '1', 'true', 'True']: + return True + if x in [False, 0, '0', 'false', 'False']: + return False + raise ValueError +else: + def boolean(x): + if x in [True, 1, '1', 'true', 'True']: + return "true" + if x in [False, 0, '0', 'false', 'False']: + return "false" + raise ValueError def integer(x): From 866706db0441f32a72ed03f062bf135a071baae7 Mon Sep 17 00:00:00 2001 From: Ben Bridts Date: Fri, 31 Aug 2018 12:21:53 +0200 Subject: [PATCH 3/4] Find-Replace boolean strings in tests --- tests/examples_output/Autoscaling.template | 10 ++++---- .../AutoscalingHTTPRequests.template | 10 ++++---- .../examples_output/ClassExtensions.template | 4 ++-- .../CloudFront_Distribution_S3.template | 4 ++-- tests/examples_output/CloudTrail.template | 2 +- tests/examples_output/ECSCluster.template | 6 ++--- tests/examples_output/ECSFargate.template | 2 +- tests/examples_output/ELBSample.template | 2 +- tests/examples_output/EMR_Cluster.template | 8 +++---- .../examples_output/ElastiCacheRedis.template | 8 +++---- .../ElasticsearchDomain.template | 8 +++---- .../Firehose_with_Redshift.template | 4 ++-- tests/examples_output/IoTSample.template | 2 +- tests/examples_output/NatGateway.template | 4 ++-- .../OpenStack_AutoScaling.template | 4 ++-- .../examples_output/OpsWorksSnippet.template | 16 ++++++------- tests/examples_output/Redshift.template | 2 +- .../RedshiftClusterInVpc.template | 2 +- ...With_Multiple_Dynamic_IPAddresses.template | 2 +- .../VPC_With_VPN_Connection.template | 10 ++++---- .../VPC_single_instance_in_subnet.template | 24 +++++++++---------- .../WAF_Common_Attacks_Sample.template | 8 +++---- ...AF_Regional_Common_Attacks_Sample.template | 8 +++---- 23 files changed, 75 insertions(+), 75 deletions(-) diff --git a/tests/examples_output/Autoscaling.template b/tests/examples_output/Autoscaling.template index add58fa28..9ffbedfbf 100644 --- a/tests/examples_output/Autoscaling.template +++ b/tests/examples_output/Autoscaling.template @@ -129,13 +129,13 @@ "Type": "AWS::AutoScaling::AutoScalingGroup", "UpdatePolicy": { "AutoScalingReplacingUpdate": { - "WillReplace": "true" + "WillReplace": true }, "AutoScalingRollingUpdate": { "MaxBatchSize": "1", "MinInstancesInService": "1", "PauseTime": "PT5M", - "WaitOnResourceSignals": "true" + "WaitOnResourceSignals": true } } }, @@ -181,8 +181,8 @@ "services": { "sysvinit": { "rsyslog": { - "enabled": "true", - "ensureRunning": "true", + "enabled": true, + "ensureRunning": true, "files": [ "/etc/rsyslog.d/20-somethin.conf" ] @@ -243,7 +243,7 @@ "Enabled": true, "Timeout": 120 }, - "CrossZone": "true", + "CrossZone": true, "HealthCheck": { "HealthyThreshold": "5", "Interval": "20", diff --git a/tests/examples_output/AutoscalingHTTPRequests.template b/tests/examples_output/AutoscalingHTTPRequests.template index 6e08c97e3..0f2600052 100644 --- a/tests/examples_output/AutoscalingHTTPRequests.template +++ b/tests/examples_output/AutoscalingHTTPRequests.template @@ -129,13 +129,13 @@ "Type": "AWS::AutoScaling::AutoScalingGroup", "UpdatePolicy": { "AutoScalingReplacingUpdate": { - "WillReplace": "true" + "WillReplace": true }, "AutoScalingRollingUpdate": { "MaxBatchSize": "1", "MinInstancesInService": "1", "PauseTime": "PT5M", - "WaitOnResourceSignals": "true" + "WaitOnResourceSignals": true } } }, @@ -218,8 +218,8 @@ "services": { "sysvinit": { "rsyslog": { - "enabled": "true", - "ensureRunning": "true", + "enabled": true, + "ensureRunning": true, "files": [ "/etc/rsyslog.d/20-somethin.conf" ] @@ -280,7 +280,7 @@ "Enabled": true, "Timeout": 120 }, - "CrossZone": "true", + "CrossZone": true, "HealthCheck": { "HealthyThreshold": "5", "Interval": "20", diff --git a/tests/examples_output/ClassExtensions.template b/tests/examples_output/ClassExtensions.template index e588d4b1f..f8e676e6a 100644 --- a/tests/examples_output/ClassExtensions.template +++ b/tests/examples_output/ClassExtensions.template @@ -4,7 +4,7 @@ "Properties": { "ImageId": "ami-xxxx", "InstanceType": "t1.micro", - "Monitoring": "true", + "Monitoring": true, "SecurityGroups": [ "frontend" ] @@ -15,7 +15,7 @@ "Properties": { "ImageId": "ami-xxxx", "InstanceType": "m2.large", - "Monitoring": "true", + "Monitoring": true, "SecurityGroups": [ "processing" ] diff --git a/tests/examples_output/CloudFront_Distribution_S3.template b/tests/examples_output/CloudFront_Distribution_S3.template index 1e100c70b..1e940e1b8 100644 --- a/tests/examples_output/CloudFront_Distribution_S3.template +++ b/tests/examples_output/CloudFront_Distribution_S3.template @@ -35,12 +35,12 @@ "DistributionConfig": { "DefaultCacheBehavior": { "ForwardedValues": { - "QueryString": "false" + "QueryString": false }, "TargetOriginId": "Origin 1", "ViewerProtocolPolicy": "allow-all" }, - "Enabled": "true", + "Enabled": true, "HttpVersion": "http2", "Origins": [ { diff --git a/tests/examples_output/CloudTrail.template b/tests/examples_output/CloudTrail.template index 76749855f..f58b4c6bc 100644 --- a/tests/examples_output/CloudTrail.template +++ b/tests/examples_output/CloudTrail.template @@ -115,7 +115,7 @@ "TopicPolicy" ], "Properties": { - "IsLogging": "true", + "IsLogging": true, "S3BucketName": { "Ref": "S3Bucket" }, diff --git a/tests/examples_output/ECSCluster.template b/tests/examples_output/ECSCluster.template index 023643471..9fc99aeed 100644 --- a/tests/examples_output/ECSCluster.template +++ b/tests/examples_output/ECSCluster.template @@ -89,8 +89,8 @@ }, "services": { "cfn-hup": { - "enabled": "true", - "ensureRunning": "true", + "enabled": true, + "ensureRunning": true, "files": [ "/etc/cfn/cfn-hup.conf", "/etc/cfn/hooks.d/cfn-auto-reloader.conf" @@ -101,7 +101,7 @@ } }, "Properties": { - "AssociatePublicIpAddress": "true", + "AssociatePublicIpAddress": true, "IamInstanceProfile": { "Ref": "EC2InstanceProfile" }, diff --git a/tests/examples_output/ECSFargate.template b/tests/examples_output/ECSFargate.template index 996ab23ed..ed13e38b6 100644 --- a/tests/examples_output/ECSFargate.template +++ b/tests/examples_output/ECSFargate.template @@ -36,7 +36,7 @@ "Properties": { "ContainerDefinitions": [ { - "Essential": "true", + "Essential": true, "Image": "nginx", "Name": "nginx", "PortMappings": [ diff --git a/tests/examples_output/ELBSample.template b/tests/examples_output/ELBSample.template index 6fbc00960..077c4d015 100644 --- a/tests/examples_output/ELBSample.template +++ b/tests/examples_output/ELBSample.template @@ -154,7 +154,7 @@ "Enabled": true, "Timeout": 300 }, - "CrossZone": "true", + "CrossZone": true, "HealthCheck": { "HealthyThreshold": "3", "Interval": "30", diff --git a/tests/examples_output/EMR_Cluster.template b/tests/examples_output/EMR_Cluster.template index d3263224e..ab71f08c5 100644 --- a/tests/examples_output/EMR_Cluster.template +++ b/tests/examples_output/EMR_Cluster.template @@ -199,7 +199,7 @@ "VolumesPerInstance": "1" } ], - "EbsOptimized": "true" + "EbsOptimized": true }, "InstanceCount": "1", "InstanceType": "m4.large", @@ -280,7 +280,7 @@ "Value": "EMR Sample Cluster" } ], - "VisibleToAllUsers": "true" + "VisibleToAllUsers": true }, "Type": "AWS::EMR::Cluster" }, @@ -299,8 +299,8 @@ "EncryptionMode": "SSE-KMS" } }, - "EnableAtRestEncryption": "true", - "EnableInTransitEncryption": "true", + "EnableAtRestEncryption": true, + "EnableInTransitEncryption": true, "InTransitEncryptionConfiguration": { "TLSCertificateConfiguration": { "CertificateProviderType": "PEM", diff --git a/tests/examples_output/ElastiCacheRedis.template b/tests/examples_output/ElastiCacheRedis.template index 6bdb94587..2c4401371 100644 --- a/tests/examples_output/ElastiCacheRedis.template +++ b/tests/examples_output/ElastiCacheRedis.template @@ -527,16 +527,16 @@ "services": { "sysvinit": { "cfn-hup": { - "enabled": "true", - "ensureRunning": "true", + "enabled": true, + "ensureRunning": true, "files": [ "/etc/cfn/cfn-hup.conf", "/etc/cfn/hooks.d/cfn-auto-reloader.conf" ] }, "httpd": { - "enabled": "true", - "ensureRunning": "true" + "enabled": true, + "ensureRunning": true } } } diff --git a/tests/examples_output/ElasticsearchDomain.template b/tests/examples_output/ElasticsearchDomain.template index 2560bd111..534a0f8f6 100644 --- a/tests/examples_output/ElasticsearchDomain.template +++ b/tests/examples_output/ElasticsearchDomain.template @@ -17,22 +17,22 @@ "Version": "2012-10-17" }, "AdvancedOptions": { - "rest.action.multi.allow_explicit_index": "true" + "rest.action.multi.allow_explicit_index": true }, "DomainName": "ExampleElasticsearchDomain", "EBSOptions": { - "EBSEnabled": "true", + "EBSEnabled": true, "Iops": 0, "VolumeSize": 20, "VolumeType": "gp2" }, "ElasticsearchClusterConfig": { "DedicatedMasterCount": 3, - "DedicatedMasterEnabled": "true", + "DedicatedMasterEnabled": true, "DedicatedMasterType": "m3.medium.elasticsearch", "InstanceCount": 2, "InstanceType": "m3.medium.elasticsearch", - "ZoneAwarenessEnabled": "true" + "ZoneAwarenessEnabled": true }, "SnapshotOptions": { "AutomatedSnapshotStartHour": 0 diff --git a/tests/examples_output/Firehose_with_Redshift.template b/tests/examples_output/Firehose_with_Redshift.template index d26440a30..20aa4c2f6 100644 --- a/tests/examples_output/Firehose_with_Redshift.template +++ b/tests/examples_output/Firehose_with_Redshift.template @@ -7,7 +7,7 @@ "DeliveryStreamName": "MyDeliveryStream", "RedshiftDestinationConfiguration": { "CloudWatchLoggingOptions": { - "Enabled": "true", + "Enabled": true, "LogGroupName": "my-log-group", "LogStreamName": "my-log-stream" }, @@ -26,7 +26,7 @@ "SizeInMBs": 60 }, "CloudWatchLoggingOptions": { - "Enabled": "true", + "Enabled": true, "LogGroupName": "my-other-log-group", "LogStreamName": "my-other-log-stream" }, diff --git a/tests/examples_output/IoTSample.template b/tests/examples_output/IoTSample.template index 7742343f8..525237a17 100644 --- a/tests/examples_output/IoTSample.template +++ b/tests/examples_output/IoTSample.template @@ -53,7 +53,7 @@ } } ], - "RuleDisabled": "true", + "RuleDisabled": true, "Sql": "SELECT temp FROM SomeTopic WHERE temp > 60" } }, diff --git a/tests/examples_output/NatGateway.template b/tests/examples_output/NatGateway.template index 36c20503b..d5764781c 100644 --- a/tests/examples_output/NatGateway.template +++ b/tests/examples_output/NatGateway.template @@ -102,7 +102,7 @@ "CidrBlock": { "Ref": "PrivateSubnetCidr" }, - "MapPublicIpOnLaunch": "false", + "MapPublicIpOnLaunch": false, "VpcId": { "Ref": "VPC" } @@ -145,7 +145,7 @@ "CidrBlock": { "Ref": "PublicSubnetCidr" }, - "MapPublicIpOnLaunch": "true", + "MapPublicIpOnLaunch": true, "VpcId": { "Ref": "VPC" } diff --git a/tests/examples_output/OpenStack_AutoScaling.template b/tests/examples_output/OpenStack_AutoScaling.template index dc0ec5a85..de551518d 100644 --- a/tests/examples_output/OpenStack_AutoScaling.template +++ b/tests/examples_output/OpenStack_AutoScaling.template @@ -59,8 +59,8 @@ "services": { "sysvinit": { "service1": { - "enabled": "true", - "ensureRunning": "true", + "enabled": true, + "ensureRunning": true, "files": [ "/etc/service1/somefile.conf" ] diff --git a/tests/examples_output/OpsWorksSnippet.template b/tests/examples_output/OpsWorksSnippet.template index abe22c44d..edd6f5faa 100644 --- a/tests/examples_output/OpsWorksSnippet.template +++ b/tests/examples_output/OpsWorksSnippet.template @@ -41,16 +41,16 @@ "MysqlRootPassword": { "Ref": "MysqlRootPassword" }, - "MysqlRootPasswordUbiquitous": "true" + "MysqlRootPasswordUbiquitous": true }, - "AutoAssignElasticIps": "false", - "AutoAssignPublicIps": "true", + "AutoAssignElasticIps": false, + "AutoAssignPublicIps": true, "CustomRecipes": { "Setup": [ "phpapp::dbsetup" ] }, - "EnableAutoHealing": "true", + "EnableAutoHealing": true, "Name": "MyMySQL", "Shortname": "db-layer", "StackId": { @@ -165,14 +165,14 @@ }, "myLayer": { "Properties": { - "AutoAssignElasticIps": "false", - "AutoAssignPublicIps": "true", + "AutoAssignElasticIps": false, + "AutoAssignPublicIps": true, "CustomRecipes": { "Configure": [ "phpapp::appsetup" ] }, - "EnableAutoHealing": "true", + "EnableAutoHealing": true, "Name": "MyPHPApp", "Shortname": "php-app", "StackId": { @@ -221,7 +221,7 @@ ] ] }, - "UseCustomCookbooks": "true" + "UseCustomCookbooks": true }, "Type": "AWS::OpsWorks::Stack" } diff --git a/tests/examples_output/Redshift.template b/tests/examples_output/Redshift.template index d28833060..25341363c 100644 --- a/tests/examples_output/Redshift.template +++ b/tests/examples_output/Redshift.template @@ -116,7 +116,7 @@ "Parameters": [ { "ParameterName": "enable_user_activity_logging", - "ParameterValue": "true" + "ParameterValue": true } ] }, diff --git a/tests/examples_output/RedshiftClusterInVpc.template b/tests/examples_output/RedshiftClusterInVpc.template index fde1181f5..436d40646 100644 --- a/tests/examples_output/RedshiftClusterInVpc.template +++ b/tests/examples_output/RedshiftClusterInVpc.template @@ -135,7 +135,7 @@ "Parameters": [ { "ParameterName": "enable_user_activity_logging", - "ParameterValue": "true" + "ParameterValue": true } ] }, diff --git a/tests/examples_output/VPC_EC2_Instance_With_Multiple_Dynamic_IPAddresses.template b/tests/examples_output/VPC_EC2_Instance_With_Multiple_Dynamic_IPAddresses.template index 1c0130569..6ccfc408f 100644 --- a/tests/examples_output/VPC_EC2_Instance_With_Multiple_Dynamic_IPAddresses.template +++ b/tests/examples_output/VPC_EC2_Instance_With_Multiple_Dynamic_IPAddresses.template @@ -197,7 +197,7 @@ "SecondaryPrivateIpAddressCount": { "Ref": "SecondaryIPAddressCount" }, - "SourceDestCheck": "true", + "SourceDestCheck": true, "SubnetId": { "Ref": "SubnetId" }, diff --git a/tests/examples_output/VPC_With_VPN_Connection.template b/tests/examples_output/VPC_With_VPN_Connection.template index cad13a197..a919ab1e1 100644 --- a/tests/examples_output/VPC_With_VPN_Connection.template +++ b/tests/examples_output/VPC_With_VPN_Connection.template @@ -88,7 +88,7 @@ "InboundPrivateNetworkAclEntry": { "Properties": { "CidrBlock": "0.0.0.0/0", - "Egress": "false", + "Egress": false, "NetworkAclId": { "Ref": "PrivateNetworkAcl" }, @@ -105,7 +105,7 @@ "OutBoundPrivateNetworkAclEntry": { "Properties": { "CidrBlock": "0.0.0.0/0", - "Egress": "true", + "Egress": true, "NetworkAclId": { "Ref": "PrivateNetworkAcl" }, @@ -221,8 +221,8 @@ "CidrBlock": { "Ref": "VPCCIDR" }, - "EnableDnsHostnames": "true", - "EnableDnsSupport": "true", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, "Tags": [ { "Key": "Application", @@ -243,7 +243,7 @@ "CustomerGatewayId": { "Ref": "CustomerGateway" }, - "StaticRoutesOnly": "true", + "StaticRoutesOnly": true, "Type": "ipsec.1", "VpnGatewayId": { "Ref": "VPNGateway" diff --git a/tests/examples_output/VPC_single_instance_in_subnet.template b/tests/examples_output/VPC_single_instance_in_subnet.template index 5e221efec..9aad78f6d 100644 --- a/tests/examples_output/VPC_single_instance_in_subnet.template +++ b/tests/examples_output/VPC_single_instance_in_subnet.template @@ -270,7 +270,7 @@ "InboundHTTPNetworkAclEntry": { "Properties": { "CidrBlock": "0.0.0.0/0", - "Egress": "false", + "Egress": false, "NetworkAclId": { "Ref": "NetworkAcl" }, @@ -287,7 +287,7 @@ "InboundResponsePortsNetworkAclEntry": { "Properties": { "CidrBlock": "0.0.0.0/0", - "Egress": "false", + "Egress": false, "NetworkAclId": { "Ref": "NetworkAcl" }, @@ -304,7 +304,7 @@ "InboundSSHNetworkAclEntry": { "Properties": { "CidrBlock": "0.0.0.0/0", - "Egress": "false", + "Egress": false, "NetworkAclId": { "Ref": "NetworkAcl" }, @@ -375,7 +375,7 @@ "OutBoundHTTPNetworkAclEntry": { "Properties": { "CidrBlock": "0.0.0.0/0", - "Egress": "true", + "Egress": true, "NetworkAclId": { "Ref": "NetworkAcl" }, @@ -392,7 +392,7 @@ "OutBoundHTTPSNetworkAclEntry": { "Properties": { "CidrBlock": "0.0.0.0/0", - "Egress": "true", + "Egress": true, "NetworkAclId": { "Ref": "NetworkAcl" }, @@ -409,7 +409,7 @@ "OutBoundResponsePortsNetworkAclEntry": { "Properties": { "CidrBlock": "0.0.0.0/0", - "Egress": "true", + "Egress": true, "NetworkAclId": { "Ref": "NetworkAcl" }, @@ -585,16 +585,16 @@ "services": { "sysvinit": { "cfn-hup": { - "enabled": "true", - "ensureRunning": "true", + "enabled": true, + "ensureRunning": true, "files": [ "/etc/cfn/cfn-hup.conf", "/etc/cfn/hooks.d/cfn-auto-reloader.conf" ] }, "httpd": { - "enabled": "true", - "ensureRunning": "true" + "enabled": true, + "ensureRunning": true } } } @@ -627,8 +627,8 @@ }, "NetworkInterfaces": [ { - "AssociatePublicIpAddress": "true", - "DeleteOnTermination": "true", + "AssociatePublicIpAddress": true, + "DeleteOnTermination": true, "DeviceIndex": "0", "GroupSet": [ { diff --git a/tests/examples_output/WAF_Common_Attacks_Sample.template b/tests/examples_output/WAF_Common_Attacks_Sample.template index 0bbabc432..53ce7d1f2 100644 --- a/tests/examples_output/WAF_Common_Attacks_Sample.template +++ b/tests/examples_output/WAF_Common_Attacks_Sample.template @@ -38,7 +38,7 @@ "DataId": { "Ref": "WAFManualIPBlockSet" }, - "Negated": "false", + "Negated": false, "Type": "IPMatch" } ] @@ -126,7 +126,7 @@ "DataId": { "Ref": "SizeMatchSet" }, - "Negated": "false", + "Negated": false, "Type": "SizeConstraint" } ] @@ -236,7 +236,7 @@ "DataId": { "Ref": "SqliMatchSet" }, - "Negated": "false", + "Negated": false, "Type": "SqlInjectionMatch" } ] @@ -326,7 +326,7 @@ "DataId": { "Ref": "XssMatchSet" }, - "Negated": "false", + "Negated": false, "Type": "XssMatch" } ] diff --git a/tests/examples_output/WAF_Regional_Common_Attacks_Sample.template b/tests/examples_output/WAF_Regional_Common_Attacks_Sample.template index 821b49219..f8fbc0758 100644 --- a/tests/examples_output/WAF_Regional_Common_Attacks_Sample.template +++ b/tests/examples_output/WAF_Regional_Common_Attacks_Sample.template @@ -38,7 +38,7 @@ "DataId": { "Ref": "WAFManualIPBlockSet" }, - "Negated": "false", + "Negated": false, "Type": "IPMatch" } ] @@ -126,7 +126,7 @@ "DataId": { "Ref": "SizeMatchSet" }, - "Negated": "false", + "Negated": false, "Type": "SizeConstraint" } ] @@ -236,7 +236,7 @@ "DataId": { "Ref": "SqliMatchSet" }, - "Negated": "false", + "Negated": false, "Type": "SqlInjectionMatch" } ] @@ -326,7 +326,7 @@ "DataId": { "Ref": "XssMatchSet" }, - "Negated": "false", + "Negated": false, "Type": "XssMatch" } ] From 39c71b5294bfb7e6edefdfa9d9dc108d8cf3f8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ufl?= Date: Wed, 10 Jul 2019 18:05:00 +0200 Subject: [PATCH 4/4] Adjust booleans in tests and examples Redshift's `ParameterValue` is a string, see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-property-redshift-clusterparametergroup-parameter.html CloudFront StreamingDistribution's `Enabled` is a boolean, see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-streamingdistribution-streamingdistributionconfig.html and https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-streamingdistribution-trustedsigners.html Amazon EMR's `Enable*Encryption` are booleans, see https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-create-security-configuration.html#emr-encryption-intransit-cli AWS DLM's `CopyTag` is a boolean, see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dlm-lifecyclepolicy-schedule.html OpsWorks' `MysqlRootPasswordUbiquitous` seems to be a string, see https://github.com/awsdocs/aws-opsworks-user-guide/blob/master/doc_source/cli-examples-describe-layers.md Elasticsearch's `rest.action.multi.allow_explicit_index` is a boolean, see https://www.elastic.co/guide/en/elasticsearch/reference/current/url-access-control.html EC2 ClientVpnEndpoint's ConnectionLogOptions's `Enabled` is a boolean, see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-clientvpnendpoint-connectionlogoptions.html#cfn-ec2-clientvpnendpoint-connectionlogoptions-enabled MSK Cluster's EncryptionInTransit's `InCluster` is a boolean, see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-msk-cluster-encryptionintransit.html#cfn-msk-cluster-encryptionintransit-incluster Closes cloudtools/troposphere#1136 and cloudtools/troposphere#1409 --- .travis.yml | 3 +++ examples/EMR_Cluster.py | 4 ++-- examples/ElasticsearchDomain.py | 2 +- .../CloudFront_StreamingDistribution_S3.template | 4 ++-- tests/examples_output/Dlm.template | 2 +- tests/examples_output/MskCluster.template | 2 +- tests/examples_output/OpsWorksSnippet.template | 2 +- tests/examples_output/Redshift.template | 2 +- tests/examples_output/RedshiftClusterInVpc.template | 2 +- tests/examples_output/VpnEndpoint.template | 2 +- tests/test_emr.py | 4 ++-- tests/test_validators.py | 4 ++-- 12 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 747d50111..efe52a82b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ python: - "3.5" - "3.6" - "3.7.3" +env: + global: + - TROPO_REAL_BOOL=true before_install: - pip install --upgrade pip setuptools wheel diff --git a/examples/EMR_Cluster.py b/examples/EMR_Cluster.py index 87ce61d3b..28684aa1b 100644 --- a/examples/EMR_Cluster.py +++ b/examples/EMR_Cluster.py @@ -15,14 +15,14 @@ security_configuration = { 'EncryptionConfiguration': { - 'EnableInTransitEncryption': 'true', + 'EnableInTransitEncryption': True, 'InTransitEncryptionConfiguration': { 'TLSCertificateConfiguration': { 'CertificateProviderType': 'PEM', 'S3Object': 's3://MyConfigStore/artifacts/MyCerts.zip' } }, - 'EnableAtRestEncryption': 'true', + 'EnableAtRestEncryption': True, 'AtRestEncryptionConfiguration': { 'S3EncryptionConfiguration': { 'EncryptionMode': 'SSE-KMS', diff --git a/examples/ElasticsearchDomain.py b/examples/ElasticsearchDomain.py index a516c00c2..232688ba3 100644 --- a/examples/ElasticsearchDomain.py +++ b/examples/ElasticsearchDomain.py @@ -36,7 +36,7 @@ 'Action': 'es:*', 'Resource': '*' }]}, - AdvancedOptions={"rest.action.multi.allow_explicit_index": "true"}, + AdvancedOptions={"rest.action.multi.allow_explicit_index": True}, VPCOptions=VPCOptions( SubnetIds=["subnet-4f2bb123"], SecurityGroupIds=["sg-04cf048c"] diff --git a/tests/examples_output/CloudFront_StreamingDistribution_S3.template b/tests/examples_output/CloudFront_StreamingDistribution_S3.template index 22817c8ba..897a082cc 100644 --- a/tests/examples_output/CloudFront_StreamingDistribution_S3.template +++ b/tests/examples_output/CloudFront_StreamingDistribution_S3.template @@ -34,14 +34,14 @@ "Properties": { "StreamingDistributionConfig": { "Comment": "Streaming distribution", - "Enabled": "true", + "Enabled": true, "S3Origin": { "DomainName": { "Ref": "S3DNSName" } }, "TrustedSigners": { - "Enabled": "false" + "Enabled": false } } }, diff --git a/tests/examples_output/Dlm.template b/tests/examples_output/Dlm.template index 819b5a143..2293a596e 100644 --- a/tests/examples_output/Dlm.template +++ b/tests/examples_output/Dlm.template @@ -36,7 +36,7 @@ ], "Schedules": [ { - "CopyTags": "true", + "CopyTags": true, "CreateRule": { "Interval": 12, "IntervalUnit": "HOURS", diff --git a/tests/examples_output/MskCluster.template b/tests/examples_output/MskCluster.template index 558d8f393..545d51bfb 100644 --- a/tests/examples_output/MskCluster.template +++ b/tests/examples_output/MskCluster.template @@ -37,7 +37,7 @@ }, "EncryptionInTransit": { "ClientBroker": "TLSs", - "InCluster": "true" + "InCluster": true } }, "EnhancedMonitoring": "PER_BROKER", diff --git a/tests/examples_output/OpsWorksSnippet.template b/tests/examples_output/OpsWorksSnippet.template index edd6f5faa..5d520a9f1 100644 --- a/tests/examples_output/OpsWorksSnippet.template +++ b/tests/examples_output/OpsWorksSnippet.template @@ -41,7 +41,7 @@ "MysqlRootPassword": { "Ref": "MysqlRootPassword" }, - "MysqlRootPasswordUbiquitous": true + "MysqlRootPasswordUbiquitous": "true" }, "AutoAssignElasticIps": false, "AutoAssignPublicIps": true, diff --git a/tests/examples_output/Redshift.template b/tests/examples_output/Redshift.template index 25341363c..d28833060 100644 --- a/tests/examples_output/Redshift.template +++ b/tests/examples_output/Redshift.template @@ -116,7 +116,7 @@ "Parameters": [ { "ParameterName": "enable_user_activity_logging", - "ParameterValue": true + "ParameterValue": "true" } ] }, diff --git a/tests/examples_output/RedshiftClusterInVpc.template b/tests/examples_output/RedshiftClusterInVpc.template index 436d40646..fde1181f5 100644 --- a/tests/examples_output/RedshiftClusterInVpc.template +++ b/tests/examples_output/RedshiftClusterInVpc.template @@ -135,7 +135,7 @@ "Parameters": [ { "ParameterName": "enable_user_activity_logging", - "ParameterValue": true + "ParameterValue": "true" } ] }, diff --git a/tests/examples_output/VpnEndpoint.template b/tests/examples_output/VpnEndpoint.template index f26757f54..5b2e44793 100644 --- a/tests/examples_output/VpnEndpoint.template +++ b/tests/examples_output/VpnEndpoint.template @@ -12,7 +12,7 @@ ], "ClientCidrBlock": "10.0.0.0/22", "ConnectionLogOptions": { - "Enabled": "false" + "Enabled": false }, "Description": "My Client VPN Endpoint", "DnsServers": [ diff --git a/tests/test_emr.py b/tests/test_emr.py index afc83aab6..2e314d6ee 100644 --- a/tests/test_emr.py +++ b/tests/test_emr.py @@ -15,14 +15,14 @@ security_configuration = { 'EncryptionConfiguration': { - 'EnableInTransitEncryption': 'true', + 'EnableInTransitEncryption': True, 'InTransitEncryptionConfiguration': { 'TLSCertificateConfiguration': { 'CertificateProviderType': 'PEM', 'S3Object': 's3://MyConfigStore/artifacts/MyCerts.zip' } }, - 'EnableAtRestEncryption': 'true', + 'EnableAtRestEncryption': True, 'AtRestEncryptionConfiguration': { 'S3EncryptionConfiguration': { 'EncryptionMode': 'SSE-KMS', diff --git a/tests/test_validators.py b/tests/test_validators.py index df36062e2..61adbefc2 100644 --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -17,9 +17,9 @@ class TestValidators(unittest.TestCase): def test_boolean(self): for x in [True, "True", "true", 1, "1"]: - self.assertEqual(boolean(x), "true", repr(x)) + self.assertEqual(boolean(x), True, repr(x)) for x in [False, "False", "false", 0, "0"]: - self.assertEqual(boolean(x), "false", repr(x)) + self.assertEqual(boolean(x), False, repr(x)) for x in ["000", "111", "abc"]: with self.assertRaises(ValueError): boolean(x)