<s> from troposphere import Template , Parameter , Ref , Equals <EOL> from troposphere import If , Output , Join , GetAtt <EOL> from troposphere . redshift import Cluster , ClusterParameterGroup <EOL> from troposphere . redshift import AmazonRedshiftParameter , ClusterSubnetGroup <EOL> from troposphere . ec2 import VPC , Subnet , InternetGateway , VPCGatewayAttachment <EOL> from troposphere . ec2 import SecurityGroup , SecurityGroupRule <EOL> t = Template ( ) <EOL> t . add_version ( "<STR_LIT>" ) <EOL> t . add_description ( <EOL> "<STR_LIT>" ) <EOL> dbname = t . add_parameter ( Parameter ( <EOL> "<STR_LIT>" , <EOL> Description = "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> Type = "<STR_LIT>" , <EOL> Default = "<STR_LIT>" , <EOL> AllowedPattern = "<STR_LIT>" , <EOL> ) ) <EOL> clustertype = t . add_parameter ( Parameter ( <EOL> "<STR_LIT>" , <EOL> Description = "<STR_LIT>" , <EOL> Type = "<STR_LIT>" , <EOL> Default = "<STR_LIT>" , <EOL> AllowedValues = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] , <EOL> ) ) <EOL> numberofnodes = t . add_parameter ( Parameter ( <EOL> "<STR_LIT>" , <EOL> Description = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> Type = "<STR_LIT>" , <EOL> Default = "<STR_LIT:1>" , <EOL> ) ) <EOL> nodetype = t . add_parameter ( Parameter ( <EOL> "<STR_LIT>" , <EOL> Description = "<STR_LIT>" , <EOL> Type = "<STR_LIT>" , <EOL> Default = "<STR_LIT>" , <EOL> ) ) <EOL> masterusername = t . add_parameter ( Parameter ( <EOL> "<STR_LIT>" , <EOL> Description = "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> Type = "<STR_LIT>" , <EOL> Default = "<STR_LIT>" , <EOL> AllowedPattern = "<STR_LIT>" , <EOL> NoEcho = True , <EOL> ) ) <EOL> masteruserpassword = t . add_parameter ( Parameter ( <EOL> "<STR_LIT>" , <EOL> Description = "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> Type = "<STR_LIT>" , <EOL> NoEcho = True , <EOL> ) ) <EOL> conditions = { <EOL> "<STR_LIT>" : Equals ( <EOL> Ref ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" <EOL> ) , <EOL> } <EOL> for k in conditions : <EOL> t . add_condition ( k , conditions [ k ] ) <EOL> redshiftcluster = t . add_resource ( Cluster ( <EOL> "<STR_LIT>" , <EOL> ClusterType = Ref ( "<STR_LIT>" ) , <EOL> NumberOfNodes = If ( "<STR_LIT>" , <EOL> Ref ( "<STR_LIT>" ) , Ref ( "<STR_LIT>" ) ) , <EOL> NodeType = Ref ( "<STR_LIT>" ) , <EOL> DBName = Ref ( "<STR_LIT>" ) , <EOL> MasterUsername = Ref ( "<STR_LIT>" ) , <EOL> MasterUserPassword = Ref ( "<STR_LIT>" ) , <EOL> ClusterParameterGroupName = Ref ( "<STR_LIT>" ) , <EOL> VpcSecurityGroupIds = Ref ( "<STR_LIT>" ) , <EOL> ClusterSubnetGroupName = Ref ( "<STR_LIT>" ) , <EOL> ) ) <EOL> amazonredshiftparameter1 = AmazonRedshiftParameter ( <EOL> "<STR_LIT>" , <EOL> ParameterName = "<STR_LIT>" , <EOL> ParameterValue = "<STR_LIT:true>" , <EOL> ) <EOL> redshiftclusterparametergroup = t . add_resource ( ClusterParameterGroup ( <EOL> "<STR_LIT>" , <EOL> Description = "<STR_LIT>" , <EOL> ParameterGroupFamily = "<STR_LIT>" , <EOL> Parameters = [ amazonredshiftparameter1 ] , <EOL> ) ) <EOL> redshiftclustersubnetgroup = t . add_resource ( ClusterSubnetGroup ( <EOL> "<STR_LIT>" , <EOL> Description = "<STR_LIT>" , <EOL> SubnetIds = Ref ( "<STR_LIT>" ) , <EOL> ) ) <EOL> vpc = t . add_resource ( VPC ( <EOL> "<STR_LIT>" , <EOL> CidrBlock = "<STR_LIT>" , <EOL> ) ) <EOL> subnet = t . add_resource ( Subnet ( <EOL> "<STR_LIT>" , <EOL> CidrBlock = "<STR_LIT>" , <EOL> VpcId = Ref ( "<STR_LIT>" ) , <EOL> ) ) <EOL> internetgateway = t . add_resource ( InternetGateway ( <EOL> "<STR_LIT>" , <EOL> ) ) <EOL> gatewayattachment = t . add_resource ( VPCGatewayAttachment ( <EOL> "<STR_LIT>" , <EOL> VpcId = Ref ( "<STR_LIT>" ) , <EOL> InternetGatewayId = Ref ( "<STR_LIT>" ) , <EOL> ) ) <EOL> securitygroup = t . add_resource ( SecurityGroup ( <EOL> "<STR_LIT>" , <EOL> GroupDescription = "<STR_LIT>" , <EOL> SecurityGroupIngress = [ <EOL> SecurityGroupRule ( <EOL> "<STR_LIT>" , <EOL> CidrIp = "<STR_LIT>" , <EOL> FromPort = "<STR_LIT>" , <EOL> ToPort = "<STR_LIT>" , <EOL> IpProtocol = "<STR_LIT>" , <EOL> ) <EOL> ] , <EOL> VpcId = Ref ( "<STR_LIT>" ) , <EOL> ) ) <EOL> t . add_output ( Output ( <EOL> "<STR_LIT>" , <EOL> Value = Join ( "<STR_LIT::>" , [ GetAtt ( redshiftcluster , "<STR_LIT>" ) , <EOL> GetAtt ( redshiftcluster , "<STR_LIT>" ) ] ) , <EOL> ) ) <EOL> print ( t . to_json ( ) ) </s>
