Skip to content

Instantly share code, notes, and snippets.

@jipengxiang
Last active June 27, 2018 03:32
Show Gist options
  • Save jipengxiang/61ab4cc24077dbff4322baf19e243478 to your computer and use it in GitHub Desktop.
Save jipengxiang/61ab4cc24077dbff4322baf19e243478 to your computer and use it in GitHub Desktop.
Database mySQL
"MyDB" : {
"Type" : "AWS::RDS::DBInstance",
"Properties" : {
"DBName" : { "Ref" : "DBName" },
"AllocatedStorage" : { "Ref" : "DBAllocatedStorage" },
"DBInstanceClass" : { "Ref" : "DBInstanceClass" },
"Engine" : "MySQL",
"EngineVersion" : "5.5",
"MasterUsername" : { "Ref" : "DBUser" },
"MasterUserPassword" : { "Ref" : "DBPassword" },
"Tags" : [ { "Key" : "Name", "Value" : "My SQL Database" } ]
},
"DeletionPolicy" : "Snapshot"
}
"WebServer": {
"Type": "AWS::EC2::Instance",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
"packages" : {
"yum" : {
"java-1.6.0-openjdk" : [],
"tomcat6" : [],
"httpd" : []
}
},
@jipengxiang
Copy link
Author

If the CreateLargeSize condition is true, AWS CloudFormation sets the volume size to 100. If the condition is false, AWS CloudFormation sets the volume size to 10.
Example JSON
"NewVolume" : {
"Type" : "AWS::EC2::Volume",
"Properties" : {https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html
"Size" : {
"Fn::If" : [
"CreateLargeSize",
"100",
"10"
]},
"AvailabilityZone" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ]}
},
"DeletionPolicy" : "Snapshot"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment