go/example_code/cloudformation/README.md
This example demonstrates how to perform the following tasks in your default AWS Region using your default credentials:
You must have an AWS account, and have your default credentials and AWS Region configured as described in Configuring the AWS SDK for Go in the AWS SDK for Go Developer Guide.
go run CfnCodeOps.go [-o all | create | list | delete] [-n stack-name] [-t template-name]
all is the default value.-o create, -o delete, -o all, or no o flag
(which default to -o add),
-n stack-name is required.-o create, -o all, or no -o flag
(which default to -o add),
-t template-name is required.Unit tests should delete any resources they create. However, they might result in charges to your AWS account.
The unit test gets the name of the template file from the TemplateFile entry in config.json. By default this value is template.json, which creates an Amazon S3 bucket (the policy includes deleting the bucket when the stack is deleted).
The config.json file has one additional member, Debug. If you set it to true, the unit test displays additional log information.
The unit test creates and deletes a stack with a random name. The stack creates one resource, a private AWS S3 bucket in your default Region with a random name.
To run the unit test, enter:
go test
You should see something like the following, where PATH is the path to folder containing the Go files:
PASS
ok PATH 65.593s
If you want to see any log messages, enter:
go test -test.v
You should see some additional log messages. The last two lines should be similar to the previous output shown.
You can confirm it has deleted any resources it created by running:
go run CfnCrudOps.go -o list | sed /DELETE_COMPLETE/d | grep stack-