template

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package template renders the static files under the "/templates/" directory.

Index

Constants

View Source
const (
	DNSCertValidatorFileName            = "dns-cert-validator"
	DNSDelegationFileName               = "dns-delegation"
	CustomDomainFileName                = "custom-domain"
	AppRunnerCustomDomainLambdaFileName = "custom-domain-app-runner"
	AWSSDKLayerFileName                 = "aws-sdk-layer"
)

File names under "templates/".

View Source
const (
	// AWS VPC networking configuration.
	EnablePublicIP          = "ENABLED"
	DisablePublicIP         = "DISABLED"
	PublicSubnetsPlacement  = "PublicSubnets"
	PrivateSubnetsPlacement = "PrivateSubnets"

	// RuntimePlatform configuration.
	OSLinux             = "LINUX"
	OSWindowsServerFull = "WINDOWS_SERVER_2019_FULL"
	OSWindowsServerCore = "WINDOWS_SERVER_2019_CORE"

	ArchX86   = "X86_64"
	ArchARM   = "ARM"
	ArchARM64 = "ARM64"
)

Constants for workload options.

Variables

This section is empty.

Functions

func DashReplacedLogicalIDToOriginal

func DashReplacedLogicalIDToOriginal(safeLogicalID string) string

DashReplacedLogicalIDToOriginal takes a "sanitized" logical ID and converts it back to its original form, with dashes.

func EnvVarNameFunc

func EnvVarNameFunc(s string) string

EnvVarNameFunc converts an input resource name to LogicalIDSafe, then appends "Name" to the end.

func EnvVarSecretFunc added in v1.5.0

func EnvVarSecretFunc(s string) string

EnvVarSecretFunc converts an input resource name to LogicalIDSafe, then appends "Secret" to the end.

func FmtSliceFunc

func FmtSliceFunc(elems []string) string

FmtSliceFunc renders a string representation of a go string slice, surrounded by brackets and joined by commas.

func IncFunc

func IncFunc(i int) int

IncFunc increments an integer value and returns the result.

func QuoteSliceFunc

func QuoteSliceFunc(elems []string) []string

QuoteSliceFunc places quotation marks around all elements of a go string slice.

func ReplaceDashesFunc

func ReplaceDashesFunc(logicalID string) string

ReplaceDashesFunc takes a CloudFormation logical ID, and sanitizes it by removing "-" characters (not allowed) and replacing them with "DASH" (allowed by CloudFormation but not permitted in ecs-cli generated resource names).

func StripNonAlphaNumFunc

func StripNonAlphaNumFunc(s string) string

StripNonAlphaNumFunc strips non-alphanumeric characters from an input string.

func ToSnakeCaseFunc

func ToSnakeCaseFunc(s string) string

ToSnakeCaseFunc transforms a CamelCase input string s into an upper SNAKE_CASE string and returns it. For example, "usersDdbTableName" becomes "USERS_DDB_TABLE_NAME".

Types

type AdvancedCount added in v1.6.0

type AdvancedCount struct {
	Spot        *int
	Autoscaling *AutoscalingOpts
	Cps         []*CapacityProviderStrategy
}

AdvancedCount holds configuration for autoscaling and capacity provider parameters.

type AutoscalingOpts added in v0.4.0

type AutoscalingOpts struct {
	MinCapacity  *int
	MaxCapacity  *int
	CPU          *float64
	Memory       *float64
	Requests     *float64
	ResponseTime *float64
	QueueDelay   *AutoscalingQueueDelayOpts
}

AutoscalingOpts holds configuration that's needed for Auto Scaling.

type AutoscalingQueueDelayOpts added in v1.11.0

type AutoscalingQueueDelayOpts struct {
	AcceptableBacklogPerTask int
}

AutoscalingQueueDelayOpts holds configuration to scale SQS queues.

type CapacityProviderStrategy added in v1.6.0

type CapacityProviderStrategy struct {
	Base             *int
	Weight           *int
	CapacityProvider string
}

CapacityProviderStrategy holds the configuration needed for a CapacityProviderStrategyItem on a Service

type ContainerHealthCheck added in v1.11.0

type ContainerHealthCheck struct {
	Command     []string
	Interval    *int64
	Retries     *int64
	StartPeriod *int64
	Timeout     *int64
}

ContainerHealthCheck holds configuration for container health check.

type Content

type Content struct {
	*bytes.Buffer
}

Content represents the parsed template.

func (*Content) MarshalBinary

func (c *Content) MarshalBinary() ([]byte, error)

MarshalBinary returns the contents as binary and implements the encoding.BinaryMarshaler interface.

type DeadLetterQueue added in v1.9.0

type DeadLetterQueue struct {
	Tries *uint16
}

DeadLetterQueue holds information needed to render a dead-letter SQS Queue in a container definition.

type EFSPermission added in v1.3.0

type EFSPermission struct {
	FilesystemID  *string
	Write         bool
	AccessPointID *string
}

EFSPermission holds information needed to render an IAM policy statement.

type EFSVolumeConfiguration added in v1.5.0

type EFSVolumeConfiguration struct {
	// EFSVolumeConfiguration
	Filesystem    *string
	RootDirectory *string // "/" or empty are equivalent

	// Authorization Config
	AccessPointID *string
	IAM           *string // ENABLED or DISABLED
}

EFSVolumeConfiguration contains information about how to specify externally managed file systems.

type EnvOpts added in v0.3.0

type EnvOpts struct {
	AppName string // The application name. Needed to create default value for svc discovery endpoint for upgraded environments.
	Version string // The template version to use for the environment. If empty uses the "legacy" template.

	DNSDelegationLambda       string
	DNSCertValidatorLambda    string
	EnableLongARNFormatLambda string
	CustomDomainLambda        string
	ScriptBucketName          string

	ImportVPC *config.ImportVPC
	VPCConfig *config.AdjustVPC

	LatestVersion string
}

EnvOpts holds data that can be provided to enable features in an environment stack template.

type ExecuteCommandOpts added in v1.4.0

type ExecuteCommandOpts struct{}

ExecuteCommandOpts holds configuration that's needed for ECS Execute Command.

type HTTPHealthCheckOpts added in v0.6.0

type HTTPHealthCheckOpts struct {
	HealthCheckPath     string
	SuccessCodes        string
	HealthyThreshold    *int64
	UnhealthyThreshold  *int64
	Interval            *int64
	Timeout             *int64
	DeregistrationDelay *int64
	GracePeriod         *int64
}

HTTPHealthCheckOpts holds configuration that's needed for HTTP Health Check.

type LogConfigOpts

type LogConfigOpts struct {
	Image          *string
	Destination    map[string]string
	EnableMetadata *string
	SecretOptions  map[string]string
	ConfigFile     *string
	Variables      map[string]string
	Secrets        map[string]string
}

LogConfigOpts holds configuration that's needed if the service is configured with Firelens to route its logs.

type ManagedVolumeCreationInfo added in v1.5.0

type ManagedVolumeCreationInfo struct {
	Name    *string
	DirName *string
	UID     *uint32
	GID     *uint32
}

ManagedVolumeCreationInfo holds information about how to create Copilot-managed access points.

type MountPoint added in v1.3.0

type MountPoint struct {
	ContainerPath *string
	ReadOnly      *bool
	SourceVolume  *string
}

MountPoint holds information needed to render a MountPoint in a containerdefinition.

type NetworkLoadBalancer added in v1.13.0

type NetworkLoadBalancer struct {
	PublicSubnetCIDRs []string
	Listener          NetworkLoadBalancerListener
}

NetworkLoadBalancer holds configuration that's needed for a Network Load Balancer.

type NetworkLoadBalancerListener added in v1.13.0

type NetworkLoadBalancerListener struct {
	Port            string
	Protocol        string
	TargetContainer string
	TargetPort      string
	SSLPolicy       *string
}

NetworkLoadBalancerListener holds configuration that's need for a Network Load Balancer listener.

type NetworkOpts added in v1.3.0

type NetworkOpts struct {
	AssignPublicIP string
	SubnetsType    string
	SecurityGroups []string
}

NetworkOpts holds AWS networking configuration for the workloads.

type ParseOption

type ParseOption func(t *template.Template) *template.Template

ParseOption represents a functional option for the Parse method.

func WithFuncs

func WithFuncs(fns map[string]interface{}) ParseOption

WithFuncs returns a template that can parse additional custom functions.

type Parser

type Parser interface {
	Parse(path string, data interface{}, options ...ParseOption) (*Content, error)
}

Parser is the interface that wraps the Parse method.

type PublishOpts added in v1.8.3

type PublishOpts struct {
	Topics []*Topic
}

PublishOpts holds configuration needed if the service has publishers.

type ReadParser

type ReadParser interface {
	Read(path string) (*Content, error)
	Parser
}

ReadParser is the interface that wraps the Read and Parse methods.

type RuntimePlatformOpts added in v1.12.0

type RuntimePlatformOpts struct {
	OS   string
	Arch string
}

RuntimePlatformOpts holds configuration needed for Platform configuration.

func (RuntimePlatformOpts) IsDefault added in v1.12.0

func (p RuntimePlatformOpts) IsDefault() bool

IsDefault returns true if the platform matches the default docker image platform of "linux/amd64".

func (RuntimePlatformOpts) Version added in v1.12.0

func (p RuntimePlatformOpts) Version() string

Version returns the Fargate platform version based on the selected os family.

type SQSQueue added in v1.9.0

type SQSQueue struct {
	Retention  *int64
	Delay      *int64
	Timeout    *int64
	DeadLetter *DeadLetterQueue
}

SQSQueue holds information needed to render a SQS Queue in a container definition.

type SidecarOpts

type SidecarOpts struct {
	Name         *string
	Image        *string
	Essential    *bool
	Port         *string
	Protocol     *string
	CredsParam   *string
	Variables    map[string]string
	Secrets      map[string]string
	Storage      SidecarStorageOpts
	DockerLabels map[string]string
	DependsOn    map[string]string
	EntryPoint   []string
	Command      []string
	HealthCheck  *ContainerHealthCheck
}

SidecarOpts holds configuration that's needed if the service has sidecar containers.

type SidecarStorageOpts added in v1.12.0

type SidecarStorageOpts struct {
	MountPoints []*MountPoint
}

SidecarStorageOpts holds data structures for rendering Mount Points inside of a sidecar.

type StateMachineOpts added in v0.5.0

type StateMachineOpts struct {
	Timeout *int
	Retries *int
}

StateMachineOpts holds configuration needed for State Machine retries and timeout.

type StorageOpts added in v1.3.0

type StorageOpts struct {
	Ephemeral         *int
	Volumes           []*Volume
	MountPoints       []*MountPoint
	EFSPerms          []*EFSPermission
	ManagedVolumeInfo *ManagedVolumeCreationInfo // Used for delegating CreationInfo for Copilot-managed EFS.
}

StorageOpts holds data structures for rendering Volumes and Mount Points

type SubscribeOpts added in v1.9.0

type SubscribeOpts struct {
	Topics []*TopicSubscription
	Queue  *SQSQueue
}

SubscribeOpts holds configuration needed if the service has subscriptions.

func (*SubscribeOpts) HasTopicQueues added in v1.10.0

func (s *SubscribeOpts) HasTopicQueues() bool

HasTopicQueues returns true if any individual subscription has a dedicated queue.

type Template

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

Template represents the "/templates/" directory that holds static files to be embedded in the binary.

func New

func New() *Template

New returns a Template object that can be used to parse files under the "/templates/" directory.

func (*Template) Parse

func (t *Template) Parse(path string, data interface{}, options ...ParseOption) (*Content, error)

Parse parses the template under "/templates/{path}" with the specified data object and returns its content.

func (*Template) ParseBackendService

func (t *Template) ParseBackendService(data WorkloadOpts) (*Content, error)

ParseBackendService parses a backend service's CloudFormation template with the specified data object and returns its content.

func (*Template) ParseEnv added in v0.3.0

func (t *Template) ParseEnv(data *EnvOpts, options ...ParseOption) (*Content, error)

ParseEnv parses an environment's CloudFormation template with the specified data object and returns its content.

func (*Template) ParseLoadBalancedWebService

func (t *Template) ParseLoadBalancedWebService(data WorkloadOpts) (*Content, error)

ParseLoadBalancedWebService parses a load balanced web service's CloudFormation template with the specified data object and returns its content.

func (*Template) ParseRequestDrivenWebService added in v1.7.0

func (t *Template) ParseRequestDrivenWebService(data WorkloadOpts) (*Content, error)

ParseRequestDrivenWebService parses a request-driven web service's CloudFormation template with the specified data object and returns its content.

func (*Template) ParseScheduledJob added in v0.5.0

func (t *Template) ParseScheduledJob(data WorkloadOpts) (*Content, error)

ParseScheduledJob parses a scheduled job's Cloudformation Template

func (*Template) ParseWorkerService added in v1.9.0

func (t *Template) ParseWorkerService(data WorkloadOpts) (*Content, error)

ParseWorkerService parses a worker service's CloudFormation template with the specified data object and returns its content.

func (*Template) Read

func (t *Template) Read(path string) (*Content, error)

Read returns the contents of the template under "/templates/{path}".

func (*Template) UploadEnvironmentCustomResources added in v1.4.0

func (t *Template) UploadEnvironmentCustomResources(upload s3.CompressAndUploadFunc) (map[string]string, error)

UploadEnvironmentCustomResources uploads the environment custom resource scripts.

func (*Template) UploadRequestDrivenWebServiceCustomResources added in v1.9.0

func (t *Template) UploadRequestDrivenWebServiceCustomResources(upload s3.CompressAndUploadFunc) (map[string]string, error)

UploadRequestDrivenWebServiceCustomResources uploads the request driven web service custom resource scripts.

func (*Template) UploadRequestDrivenWebServiceLayers added in v1.9.0

func (t *Template) UploadRequestDrivenWebServiceLayers(upload s3.UploadFunc) (map[string]string, error)

UploadRequestDrivenWebServiceLayers uploads already-zipped layers for a request driven web service.

type Topic added in v1.9.0

type Topic struct {
	Name *string

	Region    string
	Partition string
	AccountID string
	App       string
	Env       string
	Svc       string
}

Topic holds information needed to render a SNSTopic in a container definition.

func (Topic) ARN added in v1.9.0

func (t Topic) ARN() string

ARN determines the arn for a topic using the SNSTopic name and account information

type TopicSubscription added in v1.9.0

type TopicSubscription struct {
	Name    *string
	Service *string
	Queue   *SQSQueue
}

TopicSubscription holds information needed to render a SNS Topic Subscription in a container definition.

type Uploadable added in v1.4.0

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

Uploadable is an uploadable file.

func (Uploadable) Content added in v1.4.0

func (e Uploadable) Content() []byte

Content returns the content of the custom resource script.

func (Uploadable) Name added in v1.4.0

func (e Uploadable) Name() string

Name returns the name of the custom resource script.

type Volume added in v1.3.0

type Volume struct {
	Name *string

	EFS *EFSVolumeConfiguration
}

Volume contains fields that render a volume, its name, and EFSVolumeConfiguration

type WorkloadNestedStackOpts added in v0.5.0

type WorkloadNestedStackOpts struct {
	StackName string

	VariableOutputs      []string
	SecretOutputs        []string
	PolicyOutputs        []string
	SecurityGroupOutputs []string
}

WorkloadNestedStackOpts holds configuration that's needed if the workload stack has a nested stack.

type WorkloadOpts added in v0.5.0

type WorkloadOpts struct {
	// Additional options that are common between **all** workload templates.
	Variables                map[string]string
	Secrets                  map[string]string
	Aliases                  []string
	Tags                     map[string]string        // Used by App Runner workloads to tag App Runner service resources
	NestedStack              *WorkloadNestedStackOpts // Outputs from nested stacks such as the addons stack.
	AddonsExtraParams        string                   // Additional user defined Parameters for the addons stack.
	Sidecars                 []*SidecarOpts
	LogConfig                *LogConfigOpts
	Autoscaling              *AutoscalingOpts
	CapacityProviders        []*CapacityProviderStrategy
	DesiredCountOnSpot       *int
	Storage                  *StorageOpts
	Network                  NetworkOpts
	ExecuteCommand           *ExecuteCommandOpts
	Platform                 RuntimePlatformOpts
	EntryPoint               []string
	Command                  []string
	DomainAlias              string
	DockerLabels             map[string]string
	DependsOn                map[string]string
	Publish                  *PublishOpts
	ServiceDiscoveryEndpoint string
	HTTPVersion              *string

	// Additional options for service templates.
	WorkloadType        string
	HealthCheck         *ContainerHealthCheck
	HTTPHealthCheck     HTTPHealthCheckOpts
	DeregistrationDelay *int64
	AllowedSourceIps    []string
	NLB                 *NetworkLoadBalancer

	// Lambda functions.
	RulePriorityLambda             string
	DesiredCountLambda             string
	EnvControllerLambda            string
	CredentialsParameter           string
	BacklogPerTaskCalculatorLambda string

	// Additional options for job templates.
	ScheduleExpression string
	StateMachine       *StateMachineOpts

	// Additional options for request driven web service templates.
	StartCommand      *string
	EnableHealthCheck bool
	// Input needed for the custom resource that adds a custom domain to the service.
	Alias                *string
	ScriptBucketName     *string
	CustomDomainLambda   *string
	AWSSDKLayer          *string
	AppDNSDelegationRole *string
	AppDNSName           *string

	// Additional options for worker service templates.
	Subscribe *SubscribeOpts

	// List of features to enable for testing that are not yet released.
	FeatureFlags []string
}

WorkloadOpts holds optional data that can be provided to enable features in a workload stack template.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package override provides functionality to replace content from vended templates.
Package override provides functionality to replace content from vended templates.

Jump to

Keyboard shortcuts

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