cloudformation/

directory
v0.0.0-...-e8b88a3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2021 License: Apache-2.0

README

AWS SDK for Go code examples for AWS CloudFormation

Purpose

These examples demonstrate how to perform several AWS CloudFormation operations.

Prerequisites

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.

Running the code

CreateStack/CreateStack.go

This example creates an AWS CloudFormation stack.

go run CreateStack -s STACK-NAME -t TEMPLATE-FILE

  • STACK-NAME is the name of the stack to create.
  • TEMPLATE-FILE is the name of the file containing the AWS CloudFormation template.

The unit test mocks the service client and the CreateStack function.

DeleteStack/DeleteStack.go

This example deletes an AWS CloudFormation stack.

go run DeleteStack -s STACK-NAME

  • STACK-NAME is the name of the stack to create.

The unit test mocks the service client and the DeleteStack function.

ListStacks/ListStacks.go

This example lists your AWS CloudFormation stacks.

go run ListStacks -s STATUS

  • STATUS is the status of the stacks to list. By default it lists all stacks.
Notes
  • We recommend that you grant this code least privilege, or at most the minimum permissions required to perform the task. For more information, see Grant Least Privilege in the AWS Identity and Access Management User Guide.
  • This code has not been tested in all AWS Regions. Some AWS services are available only in specific Regions.
  • Running this code might result in charges to your AWS account.

Running the unit tests

Unit tests should delete any resources they create. However, they might result in charges to your AWS account.

To run a unit test, enter the following.

go test

You should see something like the following, where PATH is the path to the folder containing the Go files.

PASS
ok      PATH 6.593s

If you want to see any log messages, enter the following.

go test -test.v

You should see some additional log messages. The last two lines should be similar to the previous output shown.

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL