deploy

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package deploy holds the structures to deploy infrastructure resources. This file defines application deployment resources.

Package deploy holds the structures to deploy infrastructure resources.

Package deploy holds the structures to deploy infrastructure resources. This file defines environment deployment resources.

Package deploy holds the structures to deploy infrastructure resources. This file defines pipeline deployment resources.

Package deploy holds the structures to deploy infrastructure resources. This file defines workload deployment resources.

Package deploy holds the structures to deploy infrastructure resources. This file defines service deployment resources.

Package deploy holds the structures to deploy infrastructure resources. This file defines workload deployment resources.

Index

Constants

View Source
const (
	// AppTagKey is tag key for Copilot app.
	AppTagKey = "copilot-application"
	// EnvTagKey is tag key for Copilot env.
	EnvTagKey = "copilot-environment"
	// ServiceTagKey is tag key for Copilot service.
	ServiceTagKey = "copilot-service"
	// PipelineTagKey is tag key for Copilot pipeline.
	PipelineTagKey = "copilot-pipeline"
	// TaskTagKey is tag key for Copilot task.
	TaskTagKey = "copilot-task"
)
View Source
const (

	// DefaultPipelineArtifactsDir is the default folder to output Copilot-generated templates.
	DefaultPipelineArtifactsDir = "infrastructure"
	// DefaultPipelineBranch is the default repository branch to use for pipeline.
	DefaultPipelineBranch = "main"
	// StageFullNamePrefix is prefix to a pipeline stage name. For example, "DeployTo-test" for a test environment stage.
	StageFullNamePrefix = "DeployTo-"
)
View Source
const (
	// WorkloadCfnTemplateNameFormat is the base output file name when `service package`
	// or `job package` is called. This is also used to render the pipeline CFN template.
	WorkloadCfnTemplateNameFormat = "%s-%s.stack.yml"
	// WorkloadCfnTemplateConfigurationNameFormat is the base output configuration
	// file name when `service package` or `job package is called. It's also used to
	// render the pipeline CFN template.
	WorkloadCfnTemplateConfigurationNameFormat = "%s-%s.params.json"
	// AddonsCfnTemplateNameFormat is the addons output file name when `service package`
	// is called.
	AddonsCfnTemplateNameFormat = "%s.addons.stack.yml"
)
View Source
const FmtTaskECRRepoName = "copilot-%s"

FmtTaskECRRepoName is the pattern used to generate the ECR repository's name

Variables

This section is empty.

Functions

func DNSDelegationRoleName added in v1.9.0

func DNSDelegationRoleName(appName string) string

DNSDelegationRoleName returns the DNSDelegation role name of the app.

func PipelineSourceFromManifest added in v1.4.0

func PipelineSourceFromManifest(mfSource *manifest.Source) (source interface{}, shouldPrompt bool, err error)

PipelineSourceFromManifest processes manifest info about the source based on provider type. The return boolean is true for CodeStar Connections sources that require a polling prompt.

Types

type AppInformation added in v1.9.0

type AppInformation struct {
	AccountPrincipalARN string
	Domain              string
	Name                string
	PermissionsBoundary string
}

AppInformation holds information about the application that need to be propagated to the env stacks and workload stacks.

func (*AppInformation) DNSDelegationRole added in v1.9.0

func (a *AppInformation) DNSDelegationRole() string

DNSDelegationRole returns the ARN of the app's DNS delegation role.

type ArtifactBucket

type ArtifactBucket struct {
	// The name of the S3 bucket.
	BucketName string

	// The ARN of the KMS key used to en/decrypt artifacts stored in this bucket.
	KeyArn string
}

ArtifactBucket represents an S3 bucket used by the CodePipeline to store intermediate artifacts produced by the pipeline.

func (*ArtifactBucket) Region

func (a *ArtifactBucket) Region() (string, error)

Region parses out the region from the ARN of the KMS key associated with the artifact bucket.

type BitbucketSource added in v1.3.0

type BitbucketSource struct {
	ProviderName         string
	Branch               string
	RepositoryURL        string
	ConnectionARN        string
	OutputArtifactFormat string
}

BitbucketSource defines the (BB) source of the artifacts to be built and deployed.

func (*BitbucketSource) Connection added in v1.5.0

func (s *BitbucketSource) Connection() string

Connection returns the ARN correlated with a ConnectionName in the pipeline manifest.

func (*BitbucketSource) ConnectionName added in v1.3.0

func (s *BitbucketSource) ConnectionName() (string, error)

ConnectionName generates a recognizable string by which the connection may be identified.

func (*BitbucketSource) Repository added in v1.3.0

func (s *BitbucketSource) Repository() (string, error)

Repository returns the repository portion. For CodeStar Connections, this needs to be in the format "some-user/my-repo."

type Build added in v1.6.0

type Build struct {
	// The URI that identifies the Docker image to use for this build project.
	Image                    string
	EnvironmentType          string
	BuildspecPath            string
	AdditionalPolicyDocument string
	Variables                map[string]string
}

Build represents CodeBuild project used in the CodePipeline to build and test Docker image.

func (*Build) Init added in v1.18.0

func (b *Build) Init(mfBuild *manifest.Build, mfDirPath string) error

Init populates the fields in Build by parsing the manifest file's "build" section.

type CodeCommitSource added in v1.1.0

type CodeCommitSource struct {
	ProviderName         string
	Branch               string
	RepositoryURL        string
	OutputArtifactFormat string
}

CodeCommitSource defines the (CC) source of the artifacts to be built and deployed.

func (*CodeCommitSource) Repository added in v1.1.0

func (s *CodeCommitSource) Repository() (string, error)

Repository returns the repository portion. For example, given "aws/amazon-copilot", this function returns "amazon-copilot".

type ConfigStoreClient

type ConfigStoreClient interface {
	GetEnvironment(appName string, environmentName string) (*config.Environment, error)
	ListEnvironments(appName string) ([]*config.Environment, error)
	ListWorkloads(appName string) ([]*config.Workload, error)
	GetService(appName, svcName string) (*config.Workload, error)
	GetJob(appName, jobname string) (*config.Workload, error)
}

ConfigStoreClient wraps config store methods utilized by deploy store.

type CreateAppInput

type CreateAppInput struct {
	Name                  string            // Name of the application that needs to be created.
	AccountID             string            // AWS account ID to administrate the application.
	DNSDelegationAccounts []string          // Accounts to grant DNS access to for this application.
	DomainName            string            // DNS Name used for this application.
	DomainHostedZoneID    string            // Hosted Zone ID for the domain.
	PermissionsBoundary   string            // Name of the IAM Managed Policy to set a permissions boundary.
	AdditionalTags        map[string]string // AdditionalTags are labels applied to resources under the application.
	Version               string            // The version of the application template to create the stack/stackset. If empty, creates the legacy stack/stackset.
}

CreateAppInput holds the fields required to create an application stack set.

type CreateEnvironmentResponse

type CreateEnvironmentResponse struct {
	Env *config.Environment
	Err error
}

CreateEnvironmentResponse holds the created environment on successful deployment. Otherwise, the environment is set to nil and a descriptive error is returned.

type CreatePipelineInput

type CreatePipelineInput struct {
	// Name of the application this pipeline belongs to
	AppName string

	// Name of the pipeline
	Name string

	// IsLegacy should be set to true if the pipeline has been deployed using a legacy non-namespaced name; otherwise it is false.
	IsLegacy bool

	// The source code provider for this pipeline
	Source interface{}

	// The build project settings for this pipeline
	Build *Build

	// The stages of the pipeline. The order of stages in this list
	// will be the order we deploy to.
	Stages []PipelineStage

	// A list of artifact buckets and corresponding KMS keys that will
	// be used in this pipeline.
	ArtifactBuckets []ArtifactBucket

	// AdditionalTags are labels applied to resources under the application.
	AdditionalTags map[string]string

	// PermissionsBoundary is the name of an IAM policy to set a permissions boundary.
	PermissionsBoundary string

	// Version is the pipeline template version.
	Version string
}

CreatePipelineInput represents the fields required to deploy a pipeline.

type CreateTaskResourcesInput

type CreateTaskResourcesInput struct {
	Name   string
	CPU    int
	Memory int

	Image                 string
	PermissionsBoundary   string
	TaskRole              string
	ExecutionRole         string
	Command               []string
	EntryPoint            []string
	EnvVars               map[string]string
	EnvFileARN            string
	SSMParamSecrets       map[string]string
	SecretsManagerSecrets map[string]string

	OS   string
	Arch string

	App string
	Env string

	AdditionalTags map[string]string
}

CreateTaskResourcesInput holds the fields required to create a task stack.

type DeleteWorkloadInput added in v0.5.0

type DeleteWorkloadInput struct {
	Name             string
	EnvName          string
	AppName          string
	ExecutionRoleARN string
}

DeleteWorkloadInput holds the fields required to delete a workload.

type DeployAction added in v1.18.0

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

DeployAction represents a CodePipeline action of category "Deploy" for a cloudformation stack.

func (*DeployAction) Name added in v1.18.0

func (a *DeployAction) Name() string

Name returns the name of the CodePipeline deploy action for a workload.

func (*DeployAction) RunOrder added in v1.18.0

func (a *DeployAction) RunOrder() int

RunOrder returns the order in which the action should run.

func (*DeployAction) StackName added in v1.18.0

func (a *DeployAction) StackName() string

StackName returns the name of the workload stack to create or update.

func (*DeployAction) TemplateConfigPath added in v1.18.0

func (a *DeployAction) TemplateConfigPath() string

TemplateConfigPath returns the path of the CloudFormation template config file generated during the build phase.

func (*DeployAction) TemplatePath added in v1.18.0

func (a *DeployAction) TemplatePath() string

TemplatePath returns the path of the CloudFormation template file generated during the build phase.

type GitHubSource added in v1.1.0

type GitHubSource struct {
	ProviderName         string
	Branch               string
	RepositoryURL        GitHubURL
	ConnectionARN        string
	OutputArtifactFormat string
}

GitHubSource (version 2) defines the source of the artifacts to be built and deployed. This version uses CodeStar Connections to authenticate access to the remote repo.

func (*GitHubSource) Connection added in v1.5.0

func (s *GitHubSource) Connection() string

Connection returns the ARN correlated with a ConnectionName in the pipeline manifest.

func (*GitHubSource) ConnectionName added in v1.4.0

func (s *GitHubSource) ConnectionName() (string, error)

ConnectionName generates a recognizable string by which the connection may be identified.

func (*GitHubSource) Owner added in v1.1.0

func (s *GitHubSource) Owner() (string, error)

Owner returns the repository owner portion. For example, given "aws/amazon-copilot", this function returns "aws".

func (*GitHubSource) Repository added in v1.1.0

func (s *GitHubSource) Repository() (string, error)

Repository returns the repository portion. For CodeStar Connections, this needs to be in the format "some-user/my-repo."

type GitHubURL added in v1.4.0

type GitHubURL string

GitHubURL is the common type for repo URLs for both GitHubSource versions: GitHubV1 (w/ access tokens) and GitHub (V2 w CodeStar Connections).

type GitHubV1Source added in v1.4.0

type GitHubV1Source struct {
	ProviderName                string
	Branch                      string
	RepositoryURL               GitHubURL
	PersonalAccessTokenSecretID string
}

GitHubV1Source defines the source of the artifacts to be built and deployed. This version uses personal access tokens and is not recommended. https://docs.aws.amazon.com/codepipeline/latest/userguide/update-github-action-connections.html

func (*GitHubV1Source) GitHubPersonalAccessTokenSecretID added in v1.4.0

func (s *GitHubV1Source) GitHubPersonalAccessTokenSecretID() (string, error)

GitHubPersonalAccessTokenSecretID returns the ID of the secret in the Secrets manager, which stores the GitHub Personal Access token if the provider is "GitHubV1".

func (*GitHubV1Source) Owner added in v1.4.0

func (s *GitHubV1Source) Owner() (string, error)

Owner returns the repository owner portion. For example, given "aws/amazon-copilot", this function returns "aws".

func (*GitHubV1Source) Repository added in v1.4.0

func (s *GitHubV1Source) Repository() (string, error)

Repository returns the repository portion. For example, given "aws/amazon-copilot", this function returns "amazon-copilot".

type ManualApprovalAction added in v1.18.0

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

ManualApprovalAction represents a stage approval action.

func (*ManualApprovalAction) Name added in v1.18.0

func (a *ManualApprovalAction) Name() string

Name returns the name of the CodePipeline approval action for the stage.

func (*ManualApprovalAction) RunOrder added in v1.18.0

func (a *ManualApprovalAction) RunOrder() int

RunOrder returns the order in which the action should run. A higher numbers means the action is run later. Actions with the same RunOrder run in parallel.

type Pipeline added in v1.16.0

type Pipeline struct {
	// The name of the application that the pipeline is associated with.
	AppName string
	// The pipeline resource name (physical resource ID) generated by CloudFormation.
	ResourceName string
	// The name given by user in the pipeline manifest.
	Name string
	// Whether the pipeline follows legacy-naming, i.e. not namespaced with "pipeline-app-".
	IsLegacy bool
}

Pipeline is a deployed pipeline.

type PipelineStage

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

PipelineStage represents configuration for each deployment stage of a workspace. A stage consists of the Config Environment the pipeline is deploying to, the containerized services that will be deployed, and test commands, if the user has opted to add any.

func (*PipelineStage) Approval added in v1.18.0

func (stg *PipelineStage) Approval() *ManualApprovalAction

Approval returns a manual approval action for the stage. If the stage does not require approval, then returns nil.

func (*PipelineStage) Deployments added in v1.18.0

func (stg *PipelineStage) Deployments() ([]DeployAction, error)

Deployments returns a list of deploy actions for the pipeline.

func (*PipelineStage) EnvManagerRoleARN added in v1.18.0

func (stg *PipelineStage) EnvManagerRoleARN() string

EnvManagerRoleARN returns the IAM role used to create or update CloudFormation stacks in an environment.

func (*PipelineStage) ExecRoleARN added in v1.18.0

func (stg *PipelineStage) ExecRoleARN() string

ExecRoleARN returns the IAM role assumed by CloudFormation to create or update resources defined in a template.

func (*PipelineStage) FullName added in v1.30.0

func (stg *PipelineStage) FullName() string

FullName returns the stage's full name.

func (*PipelineStage) Init added in v1.18.0

func (stg *PipelineStage) Init(env *config.Environment, mftStage *manifest.PipelineStage, workloads []string)

Init populates the fields in PipelineStage against a target environment, the user's manifest config, and any local workload names.

func (*PipelineStage) Name added in v1.18.0

func (stg *PipelineStage) Name() string

Name returns the stage's name.

func (*PipelineStage) PostDeployments added in v1.30.0

func (stg *PipelineStage) PostDeployments() ([]PrePostDeployAction, error)

PostDeployments returns a list of post-deployment actions for the pipeline stage.

func (*PipelineStage) PreDeployments added in v1.30.0

func (stg *PipelineStage) PreDeployments() ([]PrePostDeployAction, error)

PreDeployments returns a list of pre-deployment actions for the pipeline stage.

func (*PipelineStage) Region added in v1.18.0

func (stg *PipelineStage) Region() string

Region returns the AWS region name, such as "us-west-2", where the deployments will occur.

func (*PipelineStage) Test added in v1.18.0

func (stg *PipelineStage) Test() (*TestCommandsAction, error)

Test returns a test for the stage. If the stage does not have any test commands, then returns nil.

type PipelineStore added in v1.16.0

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

PipelineStore fetches information on deployed pipelines.

func NewPipelineStore added in v1.16.0

func NewPipelineStore(getter ResourceGetter) *PipelineStore

NewPipelineStore returns a new PipelineStore.

func (*PipelineStore) ListDeployedPipelines added in v1.16.0

func (p *PipelineStore) ListDeployedPipelines(appName string) ([]Pipeline, error)

ListDeployedPipelines returns a list of names of deployed pipelines by looking up pipeline resources with tags.

type PrePostDeployAction added in v1.30.0

type PrePostDeployAction struct {
	Build
	// contains filtered or unexported fields
}

PrePostDeployAction represents a CodePipeline action of category "Build" backed by a CodeBuild project.

func (*PrePostDeployAction) Name added in v1.30.0

func (p *PrePostDeployAction) Name() string

Name returns the name of the action.

func (*PrePostDeployAction) RunOrder added in v1.30.0

func (p *PrePostDeployAction) RunOrder() int

RunOrder returns the order in which the action should run.

type ResourceGetter added in v1.16.0

type ResourceGetter interface {
	GetResourcesByTags(resourceType string, tags map[string]string) ([]*rg.Resource, error)
}

ResourceGetter retrieves a group of resources that satisfy certain conditions, such as tags.

type SessionProvider added in v1.16.0

type SessionProvider interface {
	FromRole(roleARN, region string) (*session.Session, error)
}

SessionProvider is the interface to provide configuration for the AWS SDK's service clients.

type Store

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

Store fetches information on deployed services.

func NewStore

func NewStore(sessProvider SessionProvider, store ConfigStoreClient) (*Store, error)

NewStore returns a new store.

func (*Store) IsJobDeployed added in v1.7.0

func (s *Store) IsJobDeployed(appName, envName, jobName string) (bool, error)

IsJobDeployed returns whether a job is deployed in an environment or not by checking for a state machine.

func (*Store) IsServiceDeployed

func (s *Store) IsServiceDeployed(appName string, envName string, svcName string) (bool, error)

IsServiceDeployed returns whether a service is deployed in an environment or not.

func (*Store) IsWorkloadDeployed added in v1.29.1

func (s *Store) IsWorkloadDeployed(appName, envName, name string) (bool, error)

IsWorkloadDeployed returns whether a workload is deployed in an environment or not.

func (*Store) ListDeployedJobs added in v1.7.0

func (s *Store) ListDeployedJobs(appName string, envName string) ([]string, error)

ListDeployedJobs returns the names of deployed jobs in an environment.

func (*Store) ListDeployedServices

func (s *Store) ListDeployedServices(appName string, envName string) ([]string, error)

ListDeployedServices returns the names of deployed services in an environment.

func (*Store) ListDeployedWorkloads added in v1.29.1

func (s *Store) ListDeployedWorkloads(appName string, envName string) ([]string, error)

ListDeployedWorkloads returns the names of deployed workloads in an environment.

func (*Store) ListEnvironmentsDeployedTo

func (s *Store) ListEnvironmentsDeployedTo(appName string, svcName string) ([]string, error)

ListEnvironmentsDeployedTo returns all the environment that a service is deployed in.

func (*Store) ListSNSTopics added in v1.10.0

func (s *Store) ListSNSTopics(appName string, envName string) ([]Topic, error)

ListSNSTopics returns a list of SNS topics deployed to the current environment and tagged with Copilot identifiers.

type TaskStackInfo added in v1.1.0

type TaskStackInfo struct {
	StackName string
	App       string
	Env       string

	RoleARN string

	BucketName string
}

TaskStackInfo contains essential information about a Copilot task stack

func (TaskStackInfo) ECRRepoName added in v1.1.0

func (t TaskStackInfo) ECRRepoName() string

ECRRepoName returns the name of the ECR repo for the one-off task.

func (TaskStackInfo) TaskName added in v1.1.0

func (t TaskStackInfo) TaskName() string

TaskName returns the name of the one-off task. This is the same as the value of the copilot-task tag. For example, a stack called "task-db-migrate" will have the TaskName "db-migrate"

type TestCommandsAction added in v1.18.0

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

TestCommandsAction represents a CodePipeline action of category "Test" to validate deployments.

func (*TestCommandsAction) Commands added in v1.18.0

func (a *TestCommandsAction) Commands() []string

Commands returns the list commands to run part of the test action.

func (*TestCommandsAction) Name added in v1.18.0

func (a *TestCommandsAction) Name() string

Name returns the name of the test action.

func (*TestCommandsAction) RunOrder added in v1.18.0

func (a *TestCommandsAction) RunOrder() int

RunOrder returns the order in which the action should run. A higher numbers means the action is run later. Actions with the same RunOrder run in parallel.

type Topic added in v1.10.0

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

Topic holds information about a Copilot SNS topic and its ARN, ID, and Name.

func NewTopic added in v1.10.0

func NewTopic(inputARN string, app, env, wkld string) (*Topic, error)

NewTopic creates a new Topic struct, validating the ARN as a Copilot-managed SNS topic. This function will

func (Topic) ARN added in v1.10.0

func (t Topic) ARN() string

ARN returns the full ARN of the SNS topic.

func (Topic) Name added in v1.10.0

func (t Topic) Name() string

Name returns the name of the given topic.

func (Topic) String added in v1.10.0

func (t Topic) String() string

String returns the human-readable string which contains the topic name and workload it's associated with. Example: arn:aws:us-west-2:sns:123456789012:app-env-wkld-topic -> topic (wkld)

func (Topic) Workload added in v1.10.0

func (t Topic) Workload() string

Workload returns the workload associated with the given topic.

Directories

Path Synopsis
Package cloudformation provides functionality to deploy CLI concepts with AWS CloudFormation.
Package cloudformation provides functionality to deploy CLI concepts with AWS CloudFormation.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
stack
Package stack provides functionality to transform manifest files and additional runtime configuration into CloudFormation stacks.
Package stack provides functionality to transform manifest files and additional runtime configuration into CloudFormation stacks.
stack/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
upload
asset
Package asset provides functionality to manage static assets.
Package asset provides functionality to manage static assets.
customresource
Package customresource provides functionality to upload Copilot custom resources.
Package customresource provides functionality to upload Copilot custom resources.

Jump to

Keyboard shortcuts

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