aws

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 4 Imported by: 0

README

aws

import "github.com/slalombuild/fusion/templates/aws"

Package aws provides terraform templates for Amazon Web Services (AWS)

Index

Variables

go:embed aws_api_gateway.tmpl

var TEMPLATE_AWS_API_GATEWAY string

go:embed aws_cloudfront_distribution.tmpl

var TEMPLATE_AWS_CLOUDFRONT_DISTRIBUTION string

go:embed aws_iam_policy.tmpl

var TEMPLATE_AWS_IAM_POLICY string

go:embed aws_lambda_function.tmpl

var TEMPLATE_AWS_LAMBDA_FUNCTION string

go:embed aws_route53_hosted_zone.tmpl

var TEMPLATE_AWS_ROUTE53_ZONE string

go:embed aws_s3_bucket.tmpl

var TEMPLATE_AWS_S3_BUCKET string

go:embed aws_securitygroup.tmpl

var TEMPLATE_AWS_SECURITY_GROUP string

go:embed aws_vpc.tmpl

var TEMPLATE_AWS_VPC string

type APIGateway

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

type APIGateway struct {
    LogGroupArn    string `help:"If a CloudWatch log group already exists, put its arn here" short:"a" xor:"LogGroupArn,CreateLogGroup" required:""`
    Name           string `help:"API gateway name" required:"" default:"Fusion API gateway"`
    CreateLogGroup bool   `help:"If a CloudWatch log group does not already exist, set this to true to create one" short:"c" xor:"LogGroupArn,CreateLogGroup" enum:"true,false" default:"true" required:""`
}
func (*APIGateway) Render
func (resource *APIGateway) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the APIGatewayv2

type CloudfrontDistribution

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

type CloudfrontDistribution struct {
    LoggingBucketName string `help:"Name for a new s3 bucket that will contain all cloudfront logs"`
    OriginBucketName  string `help:"Name of the origin s3 bucket"`
    CloudfrontAlias   string `help:"DNS alias for cloudfront"`
}
func (*CloudfrontDistribution) Render
func (resource *CloudfrontDistribution) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the CloudFront

type IamPolicy

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

type IamPolicy struct {
    Name        string      `help:"Name of the IAM policy" required:""`
    Description string      `help:"Description of the IAM policy" default:"" short:"d"`
    Path        string      `help:"Path of the IAM Policy" default:"/" short:"p"`
    PolicyJSON  interface{} `help:"Body of the IAM policy via json file" required:"" short:"j" type:"jsonfile"`
}
func (*IamPolicy) Render
func (resource *IamPolicy) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the IamPolicy

Example

{
	policy := &IamPolicy{
		Name:        "example-policy",
		Description: "A policy description",
		PolicyJSON: strings.TrimSpace(`{
			"Version": "2012-10-17",
			"Statement": [
				{
					"Effect": "Allow",
					"Action": [
						"ec2:AttachVolume",
						"ec2:DetachVolume"
					],
					"Resource": "arn:aws:ec2:*:*:instance/*",
					"Condition": {
						"StringEquals": {"aws:ResourceTag/Department": "Development"}
					}
				},
				{
					"Effect": "Allow",
					"Action": [
						"ec2:AttachVolume",
						"ec2:DetachVolume"
					],
					"Resource": "arn:aws:ec2:*:*:volume/*",
					"Condition": {
						"StringEquals": {"aws:ResourceTag/VolumeUser": "${aws:username}"}
					}
				}
			]
		}`),
	}

	err := policy.Render(os.Stdout, true)
	if err != nil {
		fmt.Println("failed to render policy", err)
		os.Exit(1)
	}
}

type LambdaFunction

LambdaFunction is the template data object used to create a lambda function

type LambdaFunction struct {
    Name     string `help:"" default:"my_lambda"`
    Filename string `help:"" default:"my_lambda.zip"`
    Handler  string `help:"" default:"handler.index.js"`
    Runtime  string `help:"" default:"nodejs14.x"`
}
func NewLambdaFunction
func NewLambdaFunction(name, filename, handler, runtime string) *LambdaFunction

NewLambdaFunction creates new lambda function

func (*LambdaFunction) Render
func (resource *LambdaFunction) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the LambdaFunction

Example

{
	lambda := &LambdaFunction{
		Name:     "example-function",
		Runtime:  "node",
		Handler:  "handler.index",
		Filename: "index.js",
	}

	err := lambda.Render(os.Stdout, true)
	if err != nil {
		fmt.Println("failed to render lambda", err)
		os.Exit(1)
	}
}

type Route53HostedZone

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

type Route53HostedZone struct {
    Target string `help:"Target for the zone"`
    Zone   string `help:"Zone name"`
}
func (*Route53HostedZone) Render
func (resource *Route53HostedZone) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the Route53Stack

type S3Bucket

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

type S3Bucket struct {
    Name         string `help:"Name of the S3 Bucket" default:"fusion-bucket" required:"true"`
    StaticSite   bool   `help:"Enable static website hosting from bucket"`
    ForceDestroy bool   `help:"Destroy objects on bucket deletion" default:"false"`
}
func (*S3Bucket) Render
func (resource *S3Bucket) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the S3Bucket

type SecurityGroup

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

type SecurityGroup struct {
    PublicIngressPort     int    `help:"Public ingress port for the security group"`
    PublicIngressProtocol string `help:"Public ingress protocol for the security group"`
}
func (*SecurityGroup) Render
func (resource *SecurityGroup) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the SecurityGroup

type VPC

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

type VPC struct {
    CidrBlock      string `help:"CIDR block for the VPC, must be able to accomodate all the hosts the AZs will have" default:"10.0.0.0/16"`
    AzCount        int    `help:"Number of AZs to deploy in, will automatically distribute across AZs in that region" default:"4"`
    SubnetCapacity int    `help:"Number of ip addresses per subnet" default:"256"`
}
func (*VPC) Render
func (resource *VPC) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the VpcStackModule

Generated by gomarkdoc

Documentation

Overview

Package aws provides terraform templates for Amazon Web Services (AWS)

Index

Examples

Constants

This section is empty.

Variables

View Source
var TEMPLATE_AWS_API_GATEWAY string
View Source
var TEMPLATE_AWS_CLOUDFRONT_DISTRIBUTION string
View Source
var TEMPLATE_AWS_IAM_POLICY string
View Source
var TEMPLATE_AWS_LAMBDA_FUNCTION string
View Source
var TEMPLATE_AWS_ROUTE53_ZONE string
View Source
var TEMPLATE_AWS_S3_BUCKET string
View Source
var TEMPLATE_AWS_SECURITY_GROUP string
View Source
var TEMPLATE_AWS_VPC string

Functions

This section is empty.

Types

type APIGateway

type APIGateway struct {
	LogGroupArn    string `help:"If a CloudWatch log group already exists, put its arn here" short:"a" xor:"LogGroupArn,CreateLogGroup" required:""`
	Name           string `help:"API gateway name" required:"" default:"Fusion API gateway"`
	CreateLogGroup bool   `` /* 175-byte string literal not displayed */
}

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

func (*APIGateway) Render

func (resource *APIGateway) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the APIGatewayv2

type CloudfrontDistribution

type CloudfrontDistribution struct {
	LoggingBucketName string `help:"Name for a new s3 bucket that will contain all cloudfront logs"`
	OriginBucketName  string `help:"Name of the origin s3 bucket"`
	CloudfrontAlias   string `help:"DNS alias for cloudfront"`
}

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

func (*CloudfrontDistribution) Render

func (resource *CloudfrontDistribution) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the CloudFront

type IamPolicy

type IamPolicy struct {
	Name        string      `help:"Name of the IAM policy" required:""`
	Description string      `help:"Description of the IAM policy" default:"" short:"d"`
	Path        string      `help:"Path of the IAM Policy" default:"/" short:"p"`
	PolicyJSON  interface{} `help:"Body of the IAM policy via json file" required:"" short:"j" type:"jsonfile"`
}

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

func (*IamPolicy) Render

func (resource *IamPolicy) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the IamPolicy

Example
policy := &IamPolicy{
	Name:        "example-policy",
	Description: "A policy description",
	PolicyJSON: strings.TrimSpace(`{
			"Version": "2012-10-17",
			"Statement": [
				{
					"Effect": "Allow",
					"Action": [
						"ec2:AttachVolume",
						"ec2:DetachVolume"
					],
					"Resource": "arn:aws:ec2:*:*:instance/*",
					"Condition": {
						"StringEquals": {"aws:ResourceTag/Department": "Development"}
					}
				},
				{
					"Effect": "Allow",
					"Action": [
						"ec2:AttachVolume",
						"ec2:DetachVolume"
					],
					"Resource": "arn:aws:ec2:*:*:volume/*",
					"Condition": {
						"StringEquals": {"aws:ResourceTag/VolumeUser": "${aws:username}"}
					}
				}
			]
		}`),
}

err := policy.Render(os.Stdout, true)
if err != nil {
	fmt.Println("failed to render policy", err)
	os.Exit(1)
}
Output:

type LambdaFunction

type LambdaFunction struct {
	Name     string `help:"" default:"my_lambda"`
	Filename string `help:"" default:"my_lambda.zip"`
	Handler  string `help:"" default:"handler.index.js"`
	Runtime  string `help:"" default:"nodejs14.x"`
}

LambdaFunction is the template data object used to create a lambda function

func NewLambdaFunction

func NewLambdaFunction(name, filename, handler, runtime string) *LambdaFunction

NewLambdaFunction creates new lambda function

func (*LambdaFunction) Render

func (resource *LambdaFunction) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the LambdaFunction

Example
lambda := &LambdaFunction{
	Name:     "example-function",
	Runtime:  "node",
	Handler:  "handler.index",
	Filename: "index.js",
}

err := lambda.Render(os.Stdout, true)
if err != nil {
	fmt.Println("failed to render lambda", err)
	os.Exit(1)
}
Output:

type Route53HostedZone

type Route53HostedZone struct {
	Target string `help:"Target for the zone"`
	Zone   string `help:"Zone name"`
}

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

func (*Route53HostedZone) Render

func (resource *Route53HostedZone) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the Route53Stack

type S3Bucket

type S3Bucket struct {
	Name         string `help:"Name of the S3 Bucket" default:"fusion-bucket" required:"true"`
	StaticSite   bool   `help:"Enable static website hosting from bucket"`
	ForceDestroy bool   `help:"Destroy objects on bucket deletion" default:"false"`
}

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

func (*S3Bucket) Render

func (resource *S3Bucket) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the S3Bucket

type SecurityGroup

type SecurityGroup struct {
	PublicIngressPort     int    `help:"Public ingress port for the security group"`
	PublicIngressProtocol string `help:"Public ingress protocol for the security group"`
}

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

func (*SecurityGroup) Render

func (resource *SecurityGroup) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the SecurityGroup

type VPC

type VPC struct {
	CidrBlock      string `help:"CIDR block for the VPC, must be able to accomodate all the hosts the AZs will have" default:"10.0.0.0/16"`
	AzCount        int    `help:"Number of AZs to deploy in, will automatically distribute across AZs in that region" default:"4"`
	SubnetCapacity int    `help:"Number of ip addresses per subnet" default:"256"`
}

View the Kong CLI docs to see options for your command's flags and arguments https://github.com/alecthomas/kong#flags

func (*VPC) Render

func (resource *VPC) Render(w io.Writer, skipColor bool) error

Render generates the Terraform code for the VpcStackModule

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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