Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions internal/pkg/aws/sessions/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,11 @@ func (e *errCredRetrieval) Error() string {
// RecommendActions returns recommended actions to be taken after the error.
// Implements main.actionRecommender interface.
func (e *errCredRetrieval) RecommendActions() string {
notice := "It looks like your credential settings are misconfigured or missing"
notice := "It looks like AWS credentials are misconfigured or missing"
if e.profile != "" {
notice = fmt.Sprintf("It looks like your profile [%s] is misconfigured or missing", e.profile)
notice = fmt.Sprintf("It looks like AWS profile [%s] is misconfigured or missing", e.profile)
}
return fmt.Sprintf(`%s:
https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials
- We recommend including your credentials in the shared credentials file.
- Alternatively, you can also set credentials through
* Environment Variables
* EC2 Instance Metadata (credentials only)
More information: https://aws.github.io/copilot-cli/docs/credentials/`, notice)
}

Expand Down
17 changes: 9 additions & 8 deletions internal/pkg/cli/app_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,15 @@ func (o *showAppOpts) description() (*describe.App, error) {
return nil, fmt.Errorf("get version for application %s: %w", o.name, err)
}
return &describe.App{
Name: app.Name,
Version: version,
URI: app.Domain,
Envs: trimmedEnvs,
Services: trimmedSvcs,
Jobs: trimmedJobs,
Pipelines: pipelineInfo,
WkldDeployedtoEnvs: wkldDeployedtoEnvs,
Name: app.Name,
Version: version,
URI: app.Domain,
PermissionsBoundary: app.PermissionsBoundary,
Envs: trimmedEnvs,
Services: trimmedSvcs,
Jobs: trimmedJobs,
Pipelines: pipelineInfo,
WkldDeployedtoEnvs: wkldDeployedtoEnvs,
}, nil
}

Expand Down
152 changes: 117 additions & 35 deletions internal/pkg/cli/app_show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ func TestShowAppOpts_Execute(t *testing.T) {

setupMocks: func(m showAppMocks) {
m.storeSvc.EXPECT().GetApplication("my-app").Return(&config.Application{
Name: "my-app",
Domain: "example.com",
Name: "my-app",
Domain: "example.com",
PermissionsBoundary: "examplePermissionsBoundaryPolicy",
}, nil)
m.storeSvc.EXPECT().ListServices("my-app").Return([]*config.Workload{
{
Expand Down Expand Up @@ -231,13 +232,14 @@ func TestShowAppOpts_Execute(t *testing.T) {
m.versionGetter.EXPECT().Version().Return("v0.0.0", nil)
},

wantedContent: "{\"name\":\"my-app\",\"version\":\"v0.0.0\",\"uri\":\"example.com\",\"environments\":[{\"app\":\"\",\"name\":\"test\",\"region\":\"us-west-2\",\"accountID\":\"123456789\",\"registryURL\":\"\",\"executionRoleARN\":\"\",\"managerRoleARN\":\"\"},{\"app\":\"\",\"name\":\"prod\",\"region\":\"us-west-1\",\"accountID\":\"123456789\",\"registryURL\":\"\",\"executionRoleARN\":\"\",\"managerRoleARN\":\"\"}],\"services\":[{\"app\":\"\",\"name\":\"my-svc\",\"type\":\"lb-web-svc\"}],\"jobs\":[{\"app\":\"\",\"name\":\"my-job\",\"type\":\"Scheduled Job\"}],\"pipelines\":[{\"pipelineName\":\"my-pipeline-repo\",\"region\":\"\",\"accountId\":\"\",\"stages\":null,\"createdAt\":\"0001-01-01T00:00:00Z\",\"updatedAt\":\"0001-01-01T00:00:00Z\"},{\"pipelineName\":\"bad-goose\",\"region\":\"\",\"accountId\":\"\",\"stages\":null,\"createdAt\":\"0001-01-01T00:00:00Z\",\"updatedAt\":\"0001-01-01T00:00:00Z\"}]}\n",
wantedContent: "{\"name\":\"my-app\",\"version\":\"v0.0.0\",\"uri\":\"example.com\",\"permissionsBoundary\":\"examplePermissionsBoundaryPolicy\",\"environments\":[{\"app\":\"\",\"name\":\"test\",\"region\":\"us-west-2\",\"accountID\":\"123456789\",\"registryURL\":\"\",\"executionRoleARN\":\"\",\"managerRoleARN\":\"\"},{\"app\":\"\",\"name\":\"prod\",\"region\":\"us-west-1\",\"accountID\":\"123456789\",\"registryURL\":\"\",\"executionRoleARN\":\"\",\"managerRoleARN\":\"\"}],\"services\":[{\"app\":\"\",\"name\":\"my-svc\",\"type\":\"lb-web-svc\"}],\"jobs\":[{\"app\":\"\",\"name\":\"my-job\",\"type\":\"Scheduled Job\"}],\"pipelines\":[{\"pipelineName\":\"my-pipeline-repo\",\"region\":\"\",\"accountId\":\"\",\"stages\":null,\"createdAt\":\"0001-01-01T00:00:00Z\",\"updatedAt\":\"0001-01-01T00:00:00Z\"},{\"pipelineName\":\"bad-goose\",\"region\":\"\",\"accountId\":\"\",\"stages\":null,\"createdAt\":\"0001-01-01T00:00:00Z\",\"updatedAt\":\"0001-01-01T00:00:00Z\"}]}\n",
},
"correctly shows human output": {
setupMocks: func(m showAppMocks) {
m.storeSvc.EXPECT().GetApplication("my-app").Return(&config.Application{
Name: "my-app",
Domain: "example.com",
Name: "my-app",
Domain: "example.com",
PermissionsBoundary: "examplePermissionsBoundaryPolicy",
}, nil)
m.storeSvc.EXPECT().ListServices("my-app").Return([]*config.Workload{
{
Expand Down Expand Up @@ -281,9 +283,10 @@ func TestShowAppOpts_Execute(t *testing.T) {

wantedContent: `About

Name my-app
Version v0.0.0 (latest available: v1.1.0)
URI example.com
Name my-app
Version v0.0.0 (latest available: v1.1.0)
URI example.com
Permissions Boundary examplePermissionsBoundaryPolicy

Environments

Expand All @@ -310,8 +313,9 @@ Pipelines
"correctly shows human output with latest version": {
setupMocks: func(m showAppMocks) {
m.storeSvc.EXPECT().GetApplication("my-app").Return(&config.Application{
Name: "my-app",
Domain: "example.com",
Name: "my-app",
Domain: "example.com",
PermissionsBoundary: "examplePermissionsBoundaryPolicy",
}, nil)
m.storeSvc.EXPECT().ListServices("my-app").Return([]*config.Workload{
{
Expand Down Expand Up @@ -347,9 +351,77 @@ Pipelines

wantedContent: `About

Name my-app
Version v1.1.0
URI example.com
Name my-app
Version v1.1.0
URI example.com
Permissions Boundary examplePermissionsBoundaryPolicy

Environments

Name AccountID Region
---- --------- ------
test 123456789 us-west-2
prod 123456789 us-west-1

Workloads

Name Type Environments
---- ---- ------------
my-svc lb-web-svc prod, test
my-job Scheduled Job prod, test

Pipelines

Name
----
`,
},
"correctly shows human output when URI and Permissions Boundary are empty": {
setupMocks: func(m showAppMocks) {
m.storeSvc.EXPECT().GetApplication("my-app").Return(&config.Application{
Name: "my-app",
Domain: "",
PermissionsBoundary: "",
}, nil)
m.storeSvc.EXPECT().ListServices("my-app").Return([]*config.Workload{
{
Name: "my-svc",
Type: "lb-web-svc",
},
}, nil)
m.storeSvc.EXPECT().ListJobs("my-app").Return([]*config.Workload{
{
Name: "my-job",
Type: "Scheduled Job",
},
}, nil)
m.storeSvc.EXPECT().ListEnvironments("my-app").Return([]*config.Environment{
{
Name: "test",
Region: "us-west-2",
AccountID: "123456789",
},
{
Name: "prod",
AccountID: "123456789",
Region: "us-west-1",
},
}, nil)
m.deployStore.EXPECT().ListDeployedJobs("my-app", "test").Return([]string{"my-job"}, nil)
m.deployStore.EXPECT().ListDeployedJobs("my-app", "prod").Return([]string{"my-job"}, nil)
m.deployStore.EXPECT().ListDeployedServices("my-app", "test").Return([]string{"my-svc"}, nil)
m.deployStore.EXPECT().ListDeployedServices("my-app", "prod").Return([]string{"my-svc"}, nil)
m.pipelineLister.EXPECT().ListDeployedPipelines(mockAppName).Return([]deploy.Pipeline{}, nil)
m.versionGetter.EXPECT().Version().Return(deploy.LatestAppTemplateVersion, nil)

},

wantedContent: `About

Name my-app
Version v1.1.0
URI N/A
Permissions Boundary N/A

Environments

Expand All @@ -374,8 +446,9 @@ Pipelines
"when service/job is not deployed": {
setupMocks: func(m showAppMocks) {
m.storeSvc.EXPECT().GetApplication("my-app").Return(&config.Application{
Name: "my-app",
Domain: "example.com",
Name: "my-app",
Domain: "example.com",
PermissionsBoundary: "examplePermissionsBoundaryPolicy",
}, nil)
m.storeSvc.EXPECT().ListServices("my-app").Return([]*config.Workload{
{
Expand Down Expand Up @@ -415,9 +488,10 @@ Pipelines

wantedContent: `About

Name my-app
Version v1.1.0
URI example.com
Name my-app
Version v1.1.0
URI example.com
Permissions Boundary examplePermissionsBoundaryPolicy

Environments

Expand All @@ -442,8 +516,9 @@ Pipelines
}, "when multiple services/jobs are deployed": {
setupMocks: func(m showAppMocks) {
m.storeSvc.EXPECT().GetApplication("my-app").Return(&config.Application{
Name: "my-app",
Domain: "example.com",
Name: "my-app",
Domain: "example.com",
PermissionsBoundary: "examplePermissionsBoundaryPolicy",
}, nil)
m.storeSvc.EXPECT().ListServices("my-app").Return([]*config.Workload{
{
Expand Down Expand Up @@ -504,9 +579,10 @@ Pipelines

wantedContent: `About

Name my-app
Version v1.1.0
URI example.com
Name my-app
Version v1.1.0
URI example.com
Permissions Boundary examplePermissionsBoundaryPolicy

Environments

Expand Down Expand Up @@ -544,8 +620,9 @@ Pipelines
"returns error if fail to list environment": {
setupMocks: func(m showAppMocks) {
m.storeSvc.EXPECT().GetApplication("my-app").Return(&config.Application{
Name: "my-app",
Domain: "example.com",
Name: "my-app",
Domain: "example.com",
PermissionsBoundary: "examplePermissionsBoundaryPolicy",
}, nil)
m.storeSvc.EXPECT().ListEnvironments("my-app").Return(nil, testError)
},
Expand All @@ -557,8 +634,9 @@ Pipelines

setupMocks: func(m showAppMocks) {
m.storeSvc.EXPECT().GetApplication("my-app").Return(&config.Application{
Name: "my-app",
Domain: "example.com",
Name: "my-app",
Domain: "example.com",
PermissionsBoundary: "examplePermissionsBoundaryPolicy",
}, nil)
m.storeSvc.EXPECT().ListEnvironments("my-app").Return([]*config.Environment{
{
Expand All @@ -582,8 +660,9 @@ Pipelines

setupMocks: func(m showAppMocks) {
m.storeSvc.EXPECT().GetApplication("my-app").Return(&config.Application{
Name: "my-app",
Domain: "example.com",
Name: "my-app",
Domain: "example.com",
PermissionsBoundary: "examplePermissionsBoundaryPolicy",
}, nil)
m.storeSvc.EXPECT().ListEnvironments("my-app").Return([]*config.Environment{
{
Expand Down Expand Up @@ -613,8 +692,9 @@ Pipelines

setupMocks: func(m showAppMocks) {
m.storeSvc.EXPECT().GetApplication("my-app").Return(&config.Application{
Name: "my-app",
Domain: "example.com",
Name: "my-app",
Domain: "example.com",
PermissionsBoundary: "examplePermissionsBoundaryPolicy",
}, nil)
m.storeSvc.EXPECT().ListEnvironments("my-app").Return([]*config.Environment{
{
Expand Down Expand Up @@ -653,8 +733,9 @@ Pipelines

setupMocks: func(m showAppMocks) {
m.storeSvc.EXPECT().GetApplication("my-app").Return(&config.Application{
Name: "my-app",
Domain: "example.com",
Name: "my-app",
Domain: "example.com",
PermissionsBoundary: "examplePermissionsBoundaryPolicy",
}, nil)
m.storeSvc.EXPECT().ListEnvironments("my-app").Return([]*config.Environment{
{
Expand Down Expand Up @@ -695,8 +776,9 @@ Pipelines

setupMocks: func(m showAppMocks) {
m.storeSvc.EXPECT().GetApplication("my-app").Return(&config.Application{
Name: "my-app",
Domain: "example.com",
Name: "my-app",
Domain: "example.com",
PermissionsBoundary: "examplePermissionsBoundaryPolicy",
}, nil)
m.storeSvc.EXPECT().ListEnvironments("my-app").Return([]*config.Environment{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ Resources:
SubnetId: !Ref PublicSubnet2

NatGateway1Attachment:
Metadata:
'aws:copilot:description': 'An Elastic IP for NAT Gateway 1'
Type: AWS::EC2::EIP
Condition: CreateNATGateways
DependsOn: InternetGatewayAttachment
Expand Down Expand Up @@ -515,6 +517,8 @@ Resources:
RouteTableId: !Ref PrivateRouteTable1
SubnetId: !Ref PrivateSubnet1
NatGateway2Attachment:
Metadata:
'aws:copilot:description': 'An Elastic IP for NAT Gateway 2'
Type: AWS::EC2::EIP
Condition: CreateNATGateways
DependsOn: InternetGatewayAttachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ Resources:
SubnetId: !Ref PublicSubnet2

NatGateway1Attachment:
Metadata:
'aws:copilot:description': 'An Elastic IP for NAT Gateway 1'
Type: AWS::EC2::EIP
Condition: CreateNATGateways
DependsOn: InternetGatewayAttachment
Expand Down Expand Up @@ -206,6 +208,8 @@ Resources:
RouteTableId: !Ref PrivateRouteTable1
SubnetId: !Ref PrivateSubnet1
NatGateway2Attachment:
Metadata:
'aws:copilot:description': 'An Elastic IP for NAT Gateway 2'
Type: AWS::EC2::EIP
Condition: CreateNATGateways
DependsOn: InternetGatewayAttachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ Resources:
SubnetId: !Ref PublicSubnet2

NatGateway1Attachment:
Metadata:
'aws:copilot:description': 'An Elastic IP for NAT Gateway 1'
Type: AWS::EC2::EIP
Condition: CreateNATGateways
DependsOn: InternetGatewayAttachment
Expand Down Expand Up @@ -217,6 +219,8 @@ Resources:
RouteTableId: !Ref PrivateRouteTable1
SubnetId: !Ref PrivateSubnet1
NatGateway2Attachment:
Metadata:
'aws:copilot:description': 'An Elastic IP for NAT Gateway 2'
Type: AWS::EC2::EIP
Condition: CreateNATGateways
DependsOn: InternetGatewayAttachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ Resources:
SubnetId: !Ref PublicSubnet2

NatGateway1Attachment:
Metadata:
'aws:copilot:description': 'An Elastic IP for NAT Gateway 1'
Type: AWS::EC2::EIP
Condition: CreateNATGateways
DependsOn: InternetGatewayAttachment
Expand Down Expand Up @@ -572,6 +574,8 @@ Resources:
RouteTableId: !Ref PrivateRouteTable1
SubnetId: !Ref PrivateSubnet1
NatGateway2Attachment:
Metadata:
'aws:copilot:description': 'An Elastic IP for NAT Gateway 2'
Type: AWS::EC2::EIP
Condition: CreateNATGateways
DependsOn: InternetGatewayAttachment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ Resources:
SubnetId: !Ref PublicSubnet2

NatGateway1Attachment:
Metadata:
'aws:copilot:description': 'An Elastic IP for NAT Gateway 1'
Type: AWS::EC2::EIP
Condition: CreateNATGateways
DependsOn: InternetGatewayAttachment
Expand Down Expand Up @@ -216,6 +218,8 @@ Resources:
RouteTableId: !Ref PrivateRouteTable1
SubnetId: !Ref PrivateSubnet1
NatGateway2Attachment:
Metadata:
'aws:copilot:description': 'An Elastic IP for NAT Gateway 2'
Type: AWS::EC2::EIP
Condition: CreateNATGateways
DependsOn: InternetGatewayAttachment
Expand Down
Loading