Skip to content

mweagle/go-cloudcondenser

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

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

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published