Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.

Commit 3970a6c

Browse files
authored
Merge pull request #949 from aws/dev
Merge dev into master
2 parents 0301ac8 + 02b9a79 commit 3970a6c

File tree

17 files changed

+170
-28
lines changed

17 files changed

+170
-28
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 1.18.0
4+
* Enhancement - Print verbose messages for credential chain errors (#937)
5+
* Enhancement - Add G4 instance support (#940)
6+
* Enhancement - Add more descriptive logging to integ tests (#931)
7+
* Bug - Pull correct AMI type for G3 instance types. (#940)
8+
* Bug - Send optional fields as nil instead of "" to ECS (#938)
9+
* Bug - ecs-cli local up can now read from parameter store when forward slashes exist in parameter name (#935)
10+
311
## 1.17.0
412
* Feature - Add support for Firelens (#924)
513
* Bug - Remove spurious log warning (#926)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.17.0
1+
1.18.0

buildspec.yml

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,73 @@
11
version: 0.2
22

33
phases:
4+
install:
5+
runtime-versions:
6+
golang: 1.13
7+
pre_build:
8+
commands:
9+
# GOPATH is setup like the following in Codebuild standard 2.0 image
10+
# /go:/codebuild/output/src<some numbers>
11+
# so we copy all the source code to the appropriate location before
12+
# invoking any go command
13+
- ls -lah
14+
- mkdir -p /go/src/github.com/aws/amazon-ecs-cli
15+
- cp -R . /go/src/github.com/aws/amazon-ecs-cli/
16+
- |
17+
env -i PATH=$PATH GOPATH=`go env GOPATH` GOROOT=`go env GOROOT` GOCACHE=`go env GOCACHE` \
18+
go test -race -v -cover github.com/aws/amazon-ecs-cli/ecs-cli/modules/...
19+
# make a copy of the version.go because `go run gen/version-gen.go` will
20+
# modify it.
21+
- cp /go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/version/version.go /go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/version/_version.go
22+
# need to cd into the version package because version-gen.go assumes the relative
23+
# location of the VERSION file.
24+
- cd /go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/version/
25+
# since we are running the go program inside a Linux container, has to hardcode
26+
# the GOOS and GOARCH correspondinly regardless of what the host OS is.
27+
- GOOS=linux GOARCH=amd64 ECS_RELEASE=cleanbuild go run gen/version-gen.go
428
build:
529
commands:
6-
- make integ-test
7-
- ./bin/local/ecs-cli.test
30+
- echo "cd into $CODEBUILD_SRC_DIR"
31+
- cd $CODEBUILD_SRC_DIR
32+
- echo "Compilation context:"
33+
- echo "CODEBUILD_SOURCE_VERSION=$CODEBUILD_SOURCE_VERSION"
34+
- VERSION=`git tag --points-at HEAD`
35+
- echo "VERSION=$VERSION"
36+
- GIT_COMMIT_ID=`git rev-parse HEAD`
37+
- echo "GIT_COMMIT_ID=$GIT_COMMIT_ID"
38+
# TODO: Get rid of the VERSION file after we fully switch to the new CI/CD
39+
- CHECKED_IN_VERSION=`cat /go/src/github.com/aws/amazon-ecs-cli/VERSION`
40+
- echo "VERSION_FILE=$CHECKED_IN_VERSION"
41+
- echo "GOPATH=$GOPATH"
42+
- |
43+
# $CHECKED_IN_VERSION is not prefixed with "v", only the semantic version number,
44+
# such as 1.17.0 instead of v1.17.0, which is what normal version tags look like.
45+
if [ "$VERSION" != "v$CHECKED_IN_VERSION" ]; then
46+
echo "the VERSION file contains a version number that is different from the git tag. file: $CHECKED_IN_VERSION, tag: $VERSION"
47+
exit 1
48+
fi
49+
- GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -installsuffix cgo -a -ldflags "-s" -o aws/amazon-ecs-cli/ecs-cli-windows-amd64-$VERSION.exe github.com/aws/amazon-ecs-cli/ecs-cli/
50+
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -installsuffix cgo -a -ldflags "-s" -o aws/amazon-ecs-cli/ecs-cli-linux-amd64-$VERSION github.com/aws/amazon-ecs-cli/ecs-cli/
51+
- GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -installsuffix cgo -a -ldflags "-s" -o aws/amazon-ecs-cli/ecs-cli-darwin-amd64-$VERSION github.com/aws/amazon-ecs-cli/ecs-cli/
52+
finally:
53+
- echo "built artifacts:"
54+
- ls -lah aws/amazon-ecs-cli/
55+
- ./aws/amazon-ecs-cli/ecs-cli-linux-amd64-$VERSION --version
56+
post_build:
57+
commands:
58+
# restore the version file
59+
- mv /go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/version/_version.go /go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/version/version.go
60+
- echo "Creating latest artifacts..."
61+
- cp aws/amazon-ecs-cli/ecs-cli-windows-amd64-$VERSION.exe aws/amazon-ecs-cli/ecs-cli-windows-amd64-latest.exe
62+
- cp aws/amazon-ecs-cli/ecs-cli-linux-amd64-$VERSION aws/amazon-ecs-cli/ecs-cli-linux-amd64-latest
63+
- cp aws/amazon-ecs-cli/ecs-cli-darwin-amd64-$VERSION aws/amazon-ecs-cli/ecs-cli-darwin-amd64-latest
64+
- MANIFESTFILE="$GIT_COMMIT_ID.manifest"
65+
- echo "aws/amazon-ecs-cli/ecs-cli-windows-amd64-$VERSION.exe" >> $MANIFESTFILE
66+
- echo "aws/amazon-ecs-cli/ecs-cli-linux-amd64-$VERSION" >> $MANIFESTFILE
67+
- echo "aws/amazon-ecs-cli/ecs-cli-darwin-amd64-$VERSION" >> $MANIFESTFILE
68+
- echo "aws/amazon-ecs-cli/ecs-cli-windows-amd64-latest.exe" >> $MANIFESTFILE
69+
- echo "aws/amazon-ecs-cli/ecs-cli-linux-amd64-latest" >> $MANIFESTFILE
70+
- echo "aws/amazon-ecs-cli/ecs-cli-darwin-amd64-latest" >> $MANIFESTFILE
71+
artifacts:
72+
files:
73+
- '**/*'

ecs-cli/integ/cmd/compose.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ func testServiceHasAllRunningContainers(t *testing.T, p *Project, wantedNumOfCon
268268
containers := lines[1:] // Drop the headers
269269
if wantedNumOfContainers != len(containers) {
270270
t.Logf("Wanted = %d, got = %d running containers", wantedNumOfContainers, len(containers))
271+
t.Logf("Current running containers = %v", containers)
271272
return false
272273
}
273274
for _, container := range containers {
@@ -276,6 +277,7 @@ func testServiceHasAllRunningContainers(t *testing.T, p *Project, wantedNumOfCon
276277
t.Logf("Container is not RUNNING: %s", container)
277278
return false
278279
}
280+
t.Logf("Container is RUNNING: %s", container)
279281
}
280282
return true
281283
}

ecs-cli/modules/cli/local/secrets/clients/clients.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
package clients
1616

1717
import (
18-
"strings"
19-
2018
"github.com/aws/amazon-ecs-cli/ecs-cli/modules/config"
2119
"github.com/aws/aws-sdk-go/aws"
2220
arnParser "github.com/aws/aws-sdk-go/aws/arn"
@@ -62,8 +60,7 @@ func (d *SSMDecrypter) DecryptSecret(arnOrName string) (string, error) {
6260
// If the value is an ARN we need to retrieve the parameter name and update the region of the client.
6361
paramName := arnOrName
6462
if parsedARN, err := arnParser.Parse(arnOrName); err == nil {
65-
resource := strings.Split(parsedARN.Resource, "/") // Resource is formatted as parameter/{paramName}.
66-
paramName = strings.Join(resource[1:], "")
63+
paramName = parsedARN.Resource[len("parameter/"):] // Resource is formatted as parameter/{paramName}.
6764
d.SSMAPI = d.getClient(region(parsedARN.Region))
6865
}
6966

@@ -84,7 +81,10 @@ func (d *SSMDecrypter) getClient(r region) ssmiface.SSMAPI {
8481
return c
8582
}
8683
c := ssm.New(session.Must(session.NewSessionWithOptions(session.Options{
87-
Config: aws.Config{Region: aws.String(string(r))},
84+
Config: aws.Config{
85+
Region: aws.String(string(r)),
86+
CredentialsChainVerboseErrors: aws.Bool(true),
87+
},
8888
})))
8989
d.clients[r] = c
9090
return c
@@ -111,7 +111,10 @@ func (d *SecretsManagerDecrypter) getClient(r region) secretsmanageriface.Secret
111111
return c
112112
}
113113
c := secretsmanager.New(session.Must(session.NewSessionWithOptions(session.Options{
114-
Config: aws.Config{Region: aws.String(string(r))},
114+
Config: aws.Config{
115+
Region: aws.String(string(r)),
116+
CredentialsChainVerboseErrors: aws.Bool(true),
117+
},
115118
})))
116119
d.clients[r] = c
117120
return c

ecs-cli/modules/cli/local/secrets/clients/clients_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,37 @@ func TestSSMDecrypter_DecryptSecret(t *testing.T) {
116116
pdxClient.EXPECT().GetParameter(gomock.Any()).Times(0), // Should not have called PDX
117117
)
118118

119+
return &SSMDecrypter{
120+
SSMAPI: iadClient,
121+
clients: m,
122+
}
123+
},
124+
},
125+
"with forward slash": {
126+
input: "/TEST/DB/PASSWORD",
127+
wantedSecret: "hello",
128+
setupDecrypter: func(ctrl *gomock.Controller) *SSMDecrypter {
129+
iadClient := mock_ssmiface.NewMockSSMAPI(ctrl)
130+
pdxClient := mock_ssmiface.NewMockSSMAPI(ctrl)
131+
132+
m := make(map[region]ssmiface.SSMAPI)
133+
m["default"] = iadClient
134+
m["us-east-1"] = iadClient
135+
m["us-west-2"] = pdxClient
136+
137+
gomock.InOrder(
138+
iadClient.EXPECT().GetParameter(&ssm.GetParameterInput{
139+
Name: aws.String("/TEST/DB/PASSWORD"),
140+
WithDecryption: aws.Bool(true),
141+
}).Return(&ssm.GetParameterOutput{
142+
Parameter: &ssm.Parameter{
143+
Value: aws.String("hello"),
144+
},
145+
}, nil),
146+
147+
pdxClient.EXPECT().GetParameter(gomock.Any()).Times(0), // Should not have called PDX
148+
)
149+
119150
return &SSMDecrypter{
120151
SSMAPI: iadClient,
121152
clients: m,

ecs-cli/modules/clients/aws/amimetadata/client.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,21 @@ func isARM64Instance(instanceType string) bool {
111111
return false
112112
}
113113

114+
// See: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-gpu.html
114115
func isGPUInstance(instanceType string) bool {
115-
if strings.HasPrefix(instanceType, "p2.") {
116-
return true
117-
}
118-
if strings.HasPrefix(instanceType, "p3.") {
119-
return true
116+
var gpuInstanceClasses = []string{
117+
"p2.",
118+
"p3.",
119+
"p3dn.",
120+
"g3.",
121+
"g3s.",
122+
"g4dn.",
120123
}
121-
if strings.HasPrefix(instanceType, "p3dn.") {
122-
return true
124+
for _, instanceClass := range gpuInstanceClasses {
125+
126+
if strings.HasPrefix(instanceType, instanceClass) {
127+
return true
128+
}
123129
}
124130
return false
125131
}

ecs-cli/modules/clients/aws/amimetadata/client_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ func TestMetadataClient_GetRecommendedECSLinuxAMI(t *testing.T) {
4141
},
4242
nil,
4343
},
44+
{
45+
// validate that we use GPU optimized AMI for GPU instances
46+
"g4dn.xlarge",
47+
func(ssmClient *mock_ssmiface.MockSSMAPI) *mock_ssmiface.MockSSMAPI {
48+
ssmClient.EXPECT().GetParameter(gomock.Any()).Do(func(input *ssm.GetParameterInput) {
49+
assert.Equal(t, amazonLinux2X86GPURecommendedParameterName, *input.Name)
50+
}).Return(emptySSMParameterOutput(), nil)
51+
return ssmClient
52+
},
53+
nil,
54+
},
4455
{
4556
// validate that we use the generic AMI for other instances
4657
"t2.micro",

ecs-cli/modules/clients/aws/cloudformation/cluster_template.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ var clusterTemplate = `
279279
"g3.4xlarge",
280280
"g3.8xlarge",
281281
"g3.16xlarge",
282+
"g4dn.xlarge",
283+
"g4dn.2xlarge",
284+
"g4dn.4xlarge",
285+
"g4dn.8xlarge",
286+
"g4dn.12xlarge",
287+
"g4dn.16xlarge",
282288
"p2.xlarge",
283289
"p2.8xlarge",
284290
"p2.16xlarge",

ecs-cli/modules/clients/aws/cloudwatchlogs/client.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ type cwLogsClient struct {
3434

3535
// NewCloudWatchLogsClient creates an instance of ec2Client object.
3636
func NewCloudWatchLogsClient(params *config.CommandConfig, logRegion string) Client {
37-
newSession := params.Session.Copy(&aws.Config{Region: aws.String(logRegion)})
37+
newSession := params.Session.Copy(&aws.Config{
38+
Region: aws.String(logRegion),
39+
CredentialsChainVerboseErrors: aws.Bool(true),
40+
})
3841
client := cloudwatchlogs.New(newSession)
3942
client.Handlers.Build.PushBackNamed(clients.CustomUserAgentHandler())
4043
return &cwLogsClient{

0 commit comments

Comments
 (0)