Skip to content

Commit

Permalink
Update Go to 1.21 and remove Lambda stub
Browse files Browse the repository at this point in the history
  • Loading branch information
briskt committed Nov 20, 2023
1 parent 740d496 commit f512648
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.21
-
name: Run GoReleaser in snapshot mode
uses: goreleaser/goreleaser-action@v4
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ any of the running services.
This process is available as:
- A Go Module: `import "github.com/silinternational/ecs-ami-deploy/v2"`
- A command line application. See `cli/` directory
- A Lambda function that can be scheduled or triggered automatically whenever a new ECS optimized AMI is released

## Why did we build this?
AWS releases new ECS optimized AMIs on a pretty frequent basis. It's generally a good idea to keep up to
Expand All @@ -31,11 +30,10 @@ one by one, EC2 instances are removed from service and terminated, and only when
they have zero pending tasks, then the next EC2 instance can be removed from service and so forth.

## Idempotency
Gracefully replacing instances can take some time, especially for clusters with many instances supporting them. Since
it is expected that this process will be run by a Lambda, which has a runtime limit of 15 minutes, the process was
designed to be fault-tolerant and to pick up where it left off should it be killed due to timeout. One of the ways
this is accomplished is that all EC2 instances in the ASG are tagged before being detached and terminated. On successive runs
the process looks for tagged instances for the given cluster that are no longer in service and continues the graceful
Gracefully replacing instances can take some time, especially for clusters with many instances supporting them. The
process was designed to be fault-tolerant and to pick up where it left off should it terminate. One of the ways this is
accomplished is that all EC2 instances in the ASG are tagged before being detached and terminated. On successive runs
the process looks for tagged instances for the given cluster that are no longer in service and continues the graceful
termination process while monitoring the ECS cluster services for stability.

If `--force-replacement` is enabled, the process will always replace all instances whether there is a newer AMI
Expand Down
3 changes: 1 addition & 2 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ var (
var rootCmd = &cobra.Command{
Use: "ecs-ami-deploy",
Short: "Rotate AMI used in ASG for latest ECS Optimized image",
Long: `A CLI, library, and Lambda function for rotating instances in an auto-scaling group with
an updated ECS optimized image`,
Long: `A utility for rotating instances in an auto-scaling group with an updated ECS optimized image`,
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down
58 changes: 31 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,43 +1,47 @@
module github.com/silinternational/ecs-ami-deploy/v2

go 1.19
go 1.21

require (
github.com/aws/aws-lambda-go v1.37.0
github.com/aws/aws-sdk-go-v2 v1.17.5
github.com/aws/aws-sdk-go-v2/config v1.18.15
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.27.2
github.com/aws/aws-sdk-go-v2/service/ec2 v1.86.1
github.com/aws/aws-sdk-go-v2/service/ecs v1.24.0
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.15.0
github.com/aws/aws-sdk-go-v2 v1.23.1
github.com/aws/aws-sdk-go-v2/config v1.25.4
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.35.2
github.com/aws/aws-sdk-go-v2/service/ec2 v1.137.0
github.com/aws/aws-sdk-go-v2/service/ecs v1.33.2
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.17.0
)

require (
github.com/aws/aws-sdk-go-v2/credentials v1.13.15 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.23 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.29 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.23 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.30 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.23 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.12.4 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.18.5 // indirect
github.com/aws/smithy-go v1.13.5 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.16.3 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.5 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.4 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.4 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.7.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.17.3 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.20.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.25.4 // indirect
github.com/aws/smithy-go v1.17.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/spf13/afero v1.9.4 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit f512648

Please sign in to comment.