Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
cmd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Build Status

go-cloudcondenser

Compose and compile CloudFormation templates written in Go.

Overview

Define Template

var DefaultTemplate = gocc.CloudFormationCondenser{
	Description: "My Stack",
	Resources: []interface{}{
		// Dynamically assigned resource name
		gocf.IAMRole{},
		// User defined resource name
		gocc.Static("MyResource", gocf.S3Bucket{
			BucketName: gocf.String("MyS3Bucket"),
		}),
		// Multiple resources "flattened" to WebsiteResourcesXXX
		// entries. Encapsulate logical sets of related
		// CloudFormation resources
		gocc.Flatten("WebsiteResources", MultipleResourceProvider()),
		// Include free functions to annotate the template
		gocc.ProviderFunc(freeProvider),
		// Providers can conditionally update the template
		gocc.ProviderFunc(emptyProvider),
	},
}

Evaluate Template

	ctx := context.Background()
	outputTemplate, outputErr := DefaultTemplate.Evaluate(ctx)

Convert to CLI

See ./cmd/main.go for a simple CLI app that produces JSON output from a gocc.CloudFormationCondenser instance:

Results

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Resources": {
    "CloudFormerAWSIAMRole0": {
      "Type": "AWS::IAM::Role",
      "Properties": {}
    },
    "FreeResource": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "BucketName": "FreeBucket"
      }
    },
    "MyResource": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "BucketName": "MyS3Bucket"
      }
    },
    "WebsiteResourcesMultiBucket": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "BucketName": "CustomBucket"
      }
    },
    "WebsiteResourcesMultiRole": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "RoleName": "CustomRole"
      }
    }
  }
}

About

Library to produce CloudFormation templates from Go code

Resources

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.