terraform

package
v0.0.0-...-82ab749 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: BSD-3-Clause Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModulesDirname     = "modules"
	RootModulesDirname = "root-modules"
)
View Source
const (
	DefaultProviderAlias = ProviderAlias("aws")
	NetworkProviderAlias = ProviderAlias("aws.network")
	UsEast1ProviderAlias = ProviderAlias("aws.us-east-1")
)
View Source
const (
	BucketOwnerPreferred = "BucketOwnerPreferred"
	ObjectWriter         = "ObjectWriter"
)
View Source
const (
	AWSProviderVersionConstraintFilename = "terraform-aws.version-constraint"

	DefaultAWSProviderVersionConstraint = "~> 5.35"

	RequiredVersionFilename = "terraform.version"
)
View Source
const DynamoDBTableName = "terraform-state-locks"

Variables

View Source
var DefaultRequiredVersion = "" // replaced at build time with the contents of terraform.version; see Makefile

Functions

func AWSProviderVersionConstraint

func AWSProviderVersionConstraint() string

func Apply

func Apply(dirname string, autoApprove bool) error

func Destroy

func Destroy(dirname string, autoApprove bool) error

func EnsureStateManager

func EnsureStateManager(ctx context.Context, cfg *awscfg.Config) (*awsiam.Role, error)

EnsureStateManager manages an S3 bucket, a DynamoDB table, and an IAM role in the Substrate account that every other account in the organization can use to read, write, and lock Terraform state. This must be called in the Substrate account.

func Fmt

func Fmt(dirname string) error

func Init

func Init(dirname string) error

func InstalledVersion

func InstalledVersion() (string, error)

func Plan

func Plan(dirname string) error

func ProvidersLock

func ProvidersLock(dirname string) error

func RequiredVersion

func RequiredVersion() string

func Root

func Root(ctx context.Context, cfg *awscfg.Config, dirname, region string) (err error)

Root sets up the given directory as a root Terraform module by creating a few local files and AWS resources. Set it up to store remote Terraform state in the given region. It can only be called with a *Config with the Administrator role in an admin account or one already in the management account. It creates the following files: - Makefile, a convenience for running Terraform from other directories. - .gitignore, to avoid committing providers and Lambda zip files. - terraform.tf, for configuring DynamoDB/S3-backed Terraform state files. TODO factor all the code generation of providers, the shared-between-accounts module for a domain, etc. into a RootModule type

func S3BucketName

func S3BucketName(region string) string

func Scaffold

func Scaffold(domain string, commonAndSubstrateModule bool) (err error)

Scaffold generates modules/domain/{global,regional}, both setup with both modules/{common,substrate} already instantiated if commonAndSubstrateModules is true. These are the best places to put your own Terraform code to make it domain-, environment-, quality-, and region-aware.

func ShortInstalledVersion

func ShortInstalledVersion() (string, error)

func StateList

func StateList(dirname string) error

func StateRm

func StateRm(dirname string, address string) (err error)

func Upgrade

func Upgrade(dirname string) error

Types

type Block

type Block interface {
	Ref() Value
	Template() string
}

type DataSubnet

type DataSubnet struct {
	ForEach, Id Value
	Label       Value
	Provider    ProviderAlias
}

func (DataSubnet) Ref

func (d DataSubnet) Ref() Value

func (DataSubnet) Template

func (DataSubnet) Template() string

type DataSubnets

type DataSubnets struct {
	Label    Value
	Provider ProviderAlias
	Tags     Tags
	VpcId    Value
}

func (DataSubnets) Ref

func (d DataSubnets) Ref() Value

func (DataSubnets) Template

func (DataSubnets) Template() string

type DataVPC

type DataVPC struct {
	Label    Value
	Provider ProviderAlias
	Tags     Tags
}

func (DataVPC) Ref

func (d DataVPC) Ref() Value

func (DataVPC) Template

func (DataVPC) Template() string

type Directory

type Directory struct {
	ConfigurationAliases []ProviderAlias // for replacing deprecated `provider "aws" { alias = "..." }` blocks
	Files                map[string]string
	RemoveFiles          []string // it's not enough to remove a file from terraform/modules/..., we must know to remove it from end-user systems
	VersionConstraints   bool
}

func IntranetGlobalModule

func IntranetGlobalModule() *Directory

func IntranetRegionalModule

func IntranetRegionalModule() *Directory

func LambdaFunctionGlobalModule

func LambdaFunctionGlobalModule() *Directory

func LambdaFunctionRegionalModule

func LambdaFunctionRegionalModule() *Directory

func NewDirectory

func NewDirectory() *Directory

func PeeringConnectionModule

func PeeringConnectionModule() *Directory

func SubstrateGlobalModule

func SubstrateGlobalModule() *Directory

func SubstrateRegionalModule

func SubstrateRegionalModule() *Directory

func (*Directory) Write

func (d *Directory) Write(dirname string) error

type EC2Tag

type EC2Tag struct {
	DependsOn  ValueSlice
	ForEach    Value
	Key, Value Value
	Label      Value
	Provider   ProviderAlias
	ResourceId Value
}

EC2Tag generates the aws_ec2_tag resource, useful for tagging VPCs created in another account and shared into this one (because their tags don't get shared along).

func (EC2Tag) Ref

func (t EC2Tag) Ref() Value

func (EC2Tag) Template

func (EC2Tag) Template() string

type EIP

type EIP struct {
	Commented          bool // set by a command-line flag to control costs incurred by NAT Gateways
	InternetGatewayRef Value
	Label              Value
	Provider           ProviderAlias
	Tags               Tags
}

func (EIP) Ref

func (eip EIP) Ref() Value

func (EIP) Template

func (EIP) Template() string

type EgressOnlyInternetGateway

type EgressOnlyInternetGateway struct {
	Label    Value
	Provider ProviderAlias
	Tags     Tags
	VpcId    Value
}

func (EgressOnlyInternetGateway) Ref

func (egw EgressOnlyInternetGateway) Ref() Value

func (EgressOnlyInternetGateway) Template

func (EgressOnlyInternetGateway) Template() string

type File

type File struct {
	// contains filtered or unexported fields
}

func NewFile

func NewFile() *File

func (*File) Add

func (f *File) Add(b Block)

func (*File) AddAll

func (f *File) AddAll(otherFile *File)

func (*File) Len

func (f *File) Len() int

func (*File) Less

func (f *File) Less(i, j int) bool

func (*File) Swap

func (f *File) Swap(i, j int)

func (*File) Write

func (f *File) Write(pathname string) (err error)

func (*File) WriteIfNotExists

func (f *File) WriteIfNotExists(pathname string) (err error)

type InternetGateway

type InternetGateway struct {
	Label    Value
	Provider ProviderAlias
	Tags     Tags
	VpcId    Value
}

func (InternetGateway) Ref

func (igw InternetGateway) Ref() Value

func (InternetGateway) Template

func (InternetGateway) Template() string

type Module

type Module struct {
	Arguments map[string]Value
	DependsOn ValueSlice
	Label     Value
	Provider  ProviderAlias
	Providers map[ProviderAlias]ProviderAlias
	Source    Value
}

func (Module) Ref

func (m Module) Ref() Value

func (Module) Template

func (Module) Template() string

type NATGateway

type NATGateway struct {
	Commented          bool // set by a command-line flag to control costs
	InternetGatewayRef Value
	Label              Value
	Provider           ProviderAlias
	SubnetId           Value
	Tags               Tags
}

func (NATGateway) Ref

func (ngw NATGateway) Ref() Value

func (NATGateway) Template

func (NATGateway) Template() string

type Organization

type Organization struct {
	Label    Value
	Provider ProviderAlias
}

func (Organization) Ref

func (o Organization) Ref() Value

func (Organization) Template

func (Organization) Template() string

type Output

type Output struct {
	Label Value
	Value Value
}

func (Output) Ref

func (o Output) Ref() Value

func (Output) Template

func (Output) Template() string

type PrincipalAssociation

type PrincipalAssociation struct {
	Label                       Value
	Provider                    ProviderAlias
	Principal, ResourceShareArn Value
}

func (PrincipalAssociation) Ref

func (pa PrincipalAssociation) Ref() Value

func (PrincipalAssociation) Template

func (PrincipalAssociation) Template() string

type Provider

type Provider struct {
	Alias, AliasPrefix, AliasSuffix, Region string // if unset, Alias is constructed from the other three
	RoleArn                                 string
	SessionName, ExternalId                 string
}

func NetworkProviderFor

func NetworkProviderFor(region, roleArn string) Provider

NetworkProviderFor returns a Terraform provider for discovering the VPCs and subnets in the given region's network. The given sess must be in the management account (in any role).

func ProviderFor

func ProviderFor(region, roleArn string) Provider

ProviderFor returns a Terraform provider that assumes the Administrator role in sess's account in the given region.

func UsEast1Provider

func UsEast1Provider(roleArn string) Provider

UsEast1Provider returns a Terraform provider that assumes the Administrator role in sess's account in us-east-1 where it can configure services that are exclusively offered in us-east-1 such as ACM certificates for CloudFront distributions and Lambda@Edge.

See also GlobalProvider, which is for all the other global services that may be configured anywhere.

func (Provider) Ref

func (p Provider) Ref() Value

func (Provider) Template

func (Provider) Template() string

type ProviderAlias

type ProviderAlias string

func ProviderAliasFor

func ProviderAliasFor(region string) ProviderAlias

type RemoteState

type RemoteState struct {
	Config   RemoteStateConfig
	Label    Value
	Provider ProviderAlias
}

func (RemoteState) Ref

func (rs RemoteState) Ref() Value

func (RemoteState) Template

func (RemoteState) Template() string

type RemoteStateConfig

type RemoteStateConfig struct {
	Bucket, DynamoDBTable, Key, Region, RoleArn string
}

type ResourceAssociation

type ResourceAssociation struct {
	ForEach                       Value
	Label                         Value
	Provider                      ProviderAlias
	ResourceArn, ResourceShareArn Value
}

func (ResourceAssociation) Ref

func (ra ResourceAssociation) Ref() Value

func (ResourceAssociation) Template

func (ResourceAssociation) Template() string

type ResourceShare

type ResourceShare struct {
	Label    Value
	Provider ProviderAlias
	Tags     Tags
}

func (ResourceShare) Ref

func (rs ResourceShare) Ref() Value

func (ResourceShare) Template

func (ResourceShare) Template() string

type Route

type Route struct {
	Commented                                                                      bool // set by a command-line flag to control costs incurred by NAT Gateways
	DestinationIPv4, DestinationIPv6                                               Value
	EgressOnlyInternetGatewayId, InternetGatewayId, NATGatewayId, TransitGatewayId Value
	Label                                                                          Value
	Provider                                                                       ProviderAlias
	RouteTableId                                                                   Value
}

func (Route) Ref

func (r Route) Ref() Value

func (Route) Template

func (Route) Template() string

type RouteTable

type RouteTable struct {
	Label    Value
	Provider ProviderAlias
	Tags     Tags
	VpcId    Value
}

func (RouteTable) Ref

func (rt RouteTable) Ref() Value

func (RouteTable) Template

func (RouteTable) Template() string

type RouteTableAssociation

type RouteTableAssociation struct {
	Label                  Value
	Provider               ProviderAlias
	RouteTableId, SubnetId Value
}

func (RouteTableAssociation) Ref

func (rta RouteTableAssociation) Ref() Value

func (RouteTableAssociation) Template

func (RouteTableAssociation) Template() string

type S3Bucket

type S3Bucket struct {
	Bucket   Value
	Label    Value
	Policy   Value
	Provider ProviderAlias
	Tags     Tags
}

func (S3Bucket) Ref

func (b S3Bucket) Ref() Value

func (S3Bucket) Template

func (S3Bucket) Template() string

type S3BucketOwnershipControls

type S3BucketOwnershipControls struct {
	Bucket          Value
	Label           Value
	ObjectOwnership Value
	Provider        ProviderAlias
}

func (S3BucketOwnershipControls) Ref

func (boc S3BucketOwnershipControls) Ref() Value

func (S3BucketOwnershipControls) Template

func (S3BucketOwnershipControls) Template() string

type Subnet

type Subnet struct {
	AvailabilityZone         Value
	CidrBlock, IPv6CidrBlock Value
	Label                    Value
	MapPublicIPOnLaunch      bool
	Provider                 ProviderAlias
	Tags                     Tags
	VpcId                    Value
}

func (Subnet) Ref

func (s Subnet) Ref() Value

func (Subnet) Template

func (Subnet) Template() string

type Tags

type Tags struct {
	Connectivity                 string // "public" or "private"; used only by subnets
	Domain, Environment, Quality string
	Name                         string
	Region, AvailabilityZone     string
	Special                      string
}

func (Tags) Value

func (t Tags) Value() Value

type TimeSleep

type TimeSleep struct {
	CreateDuration Value
	DependsOn      ValueSlice
	ForEach        Value
	Label          Value
	Provider       ProviderAlias
}

func (TimeSleep) Ref

func (ts TimeSleep) Ref() Value

func (TimeSleep) Template

func (TimeSleep) Template() string

type VPC

type VPC struct {
	CidrBlock Value
	Label     Value
	Provider  ProviderAlias
	Tags      Tags
}

func (VPC) CidrsubnetIPv4

func (vpc VPC) CidrsubnetIPv4(newbits, netnum int) Value

func (VPC) CidrsubnetIPv6

func (vpc VPC) CidrsubnetIPv6(newbits, netnum int) Value

func (VPC) Ref

func (vpc VPC) Ref() Value

func (VPC) Template

func (VPC) Template() string

type VPCEndpoint

type VPCEndpoint struct {
	Label         Value
	Provider      ProviderAlias
	RouteTableIds ValueSlice
	ServiceName   Value
	Tags          Tags
	VpcId         Value
}

func (VPCEndpoint) Ref

func (vpce VPCEndpoint) Ref() Value

func (VPCEndpoint) Template

func (VPCEndpoint) Template() string

type Value

type Value interface {
	Empty() bool
	Raw() string
	Value() string
}

func Bool

func Bool(v bool) Value

func False

func False() Value

func Label

func Label(tags Tags, suffixes ...string) Value

Label performs a domain-specific dimensionality reduction that "feels right" enough to represent a resource with a unique label to satisfy Terraform.

func Q

func Q(args ...interface{}) Value

func Qf

func Qf(format string, args ...interface{}) Value

func True

func True() Value

func U

func U(args ...interface{}) Value

func Uf

func Uf(format string, args ...interface{}) Value

type ValueSlice

type ValueSlice []Value

func QSlice

func QSlice(ss []string) ValueSlice

func USlice

func USlice(ss []string) ValueSlice

func (ValueSlice) Empty

func (vs ValueSlice) Empty() bool

func (ValueSlice) Raw

func (vs ValueSlice) Raw() string

func (ValueSlice) Value

func (vs ValueSlice) Value() string

Jump to

Keyboard shortcuts

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