Skip to content

Commit 39d3430

Browse files
authored
Fix image-copy-ecr example. (#235)
We share this example with customers a lot but it has grown a bit stale. Mainly, the assumption that 'repository' will be equal to `<org>/<repo>` is not true and is a source of confusion. This change modifies the example to use the `repo_id` to look up the name of the repo in the Chainguard API. The name of the organization is passed in by the user when running the terraform. Also: - Remove demo instructions from the README. We don't provide write access to the registry so the instructions can't be followed. - Bump the Go version and Go modules. Signed-off-by: Rob Best <rob.best@chainguard.dev>
1 parent 08dab69 commit 39d3430

File tree

7 files changed

+345
-329
lines changed

7 files changed

+345
-329
lines changed

image-copy-ecr/README.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ terraform init
1919
terraform apply
2020
```
2121

22-
This will prompt for a group ID and destination repo, and show you the resources it will create.
22+
This will prompt for your group name and destination repo, and show you the resources it will create.
2323

2424
When the resources are created, any images that are pushed to your group will be mirrored to the ECR repository.
2525

@@ -28,22 +28,3 @@ The Lambda function has minimal permissions: it's only allowed to push images to
2828
The Chainguard identity also has minimal permissions: it only has permission to pull from the source repo.
2929

3030
To tear down resources, run `terraform destroy`.
31-
32-
## Demo
33-
34-
After setting up the infrastructure as described above:
35-
36-
```sh
37-
crane cp random.kontain.me/random cgr.dev/<org>/random:hello-demo
38-
```
39-
40-
This pulls a randomly generated image from `kontain.me` and pushes it to your private registry.
41-
42-
The Lambda function you set up will fire and copy the image to ECR. A few seconds later:
43-
44-
```sh
45-
crane ls <account-id>.dkr.ecr.<region>.amazonaws.com/<dst-repo>/random
46-
hello-demo
47-
```
48-
49-
It worked! 🎉

image-copy-ecr/go.mod

Lines changed: 77 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,96 @@
11
module github.com/chainguard-dev/platform-examples/image-copy-ecr
22

3-
go 1.21
4-
5-
toolchain go1.21.0
3+
go 1.23.4
64

75
require (
8-
chainguard.dev/sdk v0.1.1
9-
github.com/aws/aws-lambda-go v1.41.0
10-
github.com/aws/aws-sdk-go-v2/config v1.19.1
11-
github.com/aws/aws-sdk-go-v2/service/ecr v1.18.14
12-
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20230815210656-c8857611a995
13-
github.com/coreos/go-oidc v2.2.1+incompatible
14-
github.com/google/go-containerregistry v0.16.1
6+
chainguard.dev/sdk v0.1.31
7+
github.com/aws/aws-lambda-go v1.47.0
8+
github.com/aws/aws-sdk-go-v2/config v1.29.7
9+
github.com/aws/aws-sdk-go-v2/service/ecr v1.41.1
10+
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.9.1
11+
github.com/coreos/go-oidc v2.3.0+incompatible
12+
github.com/google/go-containerregistry v0.20.3
1513
github.com/kelseyhightower/envconfig v1.4.0
1614
)
1715

1816
require (
19-
chainguard.dev/go-grpc-kit v0.17.2 // indirect
20-
github.com/aws/aws-sdk-go-v2 v1.23.1 // indirect
21-
github.com/aws/aws-sdk-go-v2/credentials v1.13.43 // indirect
22-
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13 // indirect
23-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43 // indirect
24-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37 // indirect
25-
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 // indirect
26-
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.16.5 // indirect
27-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 // indirect
28-
github.com/aws/aws-sdk-go-v2/service/sso v1.15.2 // indirect
29-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.17.3 // indirect
30-
github.com/aws/aws-sdk-go-v2/service/sts v1.23.2 // indirect
31-
github.com/aws/smithy-go v1.17.0 // indirect
17+
chainguard.dev/apko v0.25.1 // indirect
18+
chainguard.dev/go-grpc-kit v0.17.7 // indirect
19+
dario.cat/mergo v1.0.1 // indirect
20+
github.com/Microsoft/go-winio v0.6.2 // indirect
21+
github.com/ProtonMail/go-crypto v1.1.5 // indirect
22+
github.com/aws/aws-sdk-go-v2 v1.36.2 // indirect
23+
github.com/aws/aws-sdk-go-v2/credentials v1.17.60 // indirect
24+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.29 // indirect
25+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.33 // indirect
26+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.33 // indirect
27+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
28+
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.31.3 // indirect
29+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
30+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.14 // indirect
31+
github.com/aws/aws-sdk-go-v2/service/sso v1.24.16 // indirect
32+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.15 // indirect
33+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.15 // indirect
34+
github.com/aws/smithy-go v1.22.3 // indirect
3235
github.com/beorn7/perks v1.0.1 // indirect
33-
github.com/blendle/zapdriver v1.3.1 // indirect
34-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
35-
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
36-
github.com/docker/cli v24.0.0+incompatible // indirect
36+
github.com/bits-and-blooms/bitset v1.20.0 // indirect
37+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
38+
github.com/chainguard-dev/clog v1.6.1 // indirect
39+
github.com/cloudflare/circl v1.6.0 // indirect
40+
github.com/containerd/stargz-snapshotter/estargz v0.16.3 // indirect
41+
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
42+
github.com/docker/cli v27.5.1+incompatible // indirect
3743
github.com/docker/distribution v2.8.3+incompatible // indirect
38-
github.com/docker/docker v25.0.6+incompatible // indirect
39-
github.com/docker/docker-credential-helpers v0.8.0 // indirect
40-
github.com/go-logr/logr v1.3.0 // indirect
44+
github.com/docker/docker-credential-helpers v0.8.2 // indirect
45+
github.com/emirpasic/gods v1.18.1 // indirect
46+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
47+
github.com/go-git/go-billy/v5 v5.6.2 // indirect
48+
github.com/go-git/go-git/v5 v5.13.2 // indirect
49+
github.com/go-logr/logr v1.4.2 // indirect
4150
github.com/go-logr/stdr v1.2.2 // indirect
42-
github.com/gogo/protobuf v1.3.2 // indirect
43-
github.com/golang/protobuf v1.5.3 // indirect
44-
github.com/google/gofuzz v1.2.0 // indirect
51+
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
52+
github.com/google/go-cmp v0.6.0 // indirect
4553
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
4654
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.1-0.20210315223345-82c243799c99 // indirect
47-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
48-
github.com/jmespath/go-jmespath v0.4.0 // indirect
49-
github.com/json-iterator/go v1.1.12 // indirect
50-
github.com/klauspost/compress v1.16.5 // indirect
51-
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
55+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 // indirect
56+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
57+
github.com/kevinburke/ssh_config v1.2.0 // indirect
58+
github.com/klauspost/compress v1.17.11 // indirect
5259
github.com/mitchellh/go-homedir v1.1.0 // indirect
53-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
54-
github.com/modern-go/reflect2 v1.0.2 // indirect
60+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5561
github.com/opencontainers/go-digest v1.0.0 // indirect
56-
github.com/opencontainers/image-spec v1.1.0-rc3 // indirect
62+
github.com/opencontainers/image-spec v1.1.0 // indirect
63+
github.com/pjbgf/sha1cd v0.3.2 // indirect
5764
github.com/pkg/errors v0.9.1 // indirect
5865
github.com/pquerna/cachecontrol v0.2.0 // indirect
59-
github.com/prometheus/client_golang v1.17.0 // indirect
60-
github.com/prometheus/client_model v0.5.0 // indirect
61-
github.com/prometheus/common v0.45.0 // indirect
62-
github.com/prometheus/procfs v0.12.0 // indirect
66+
github.com/prometheus/client_golang v1.21.0 // indirect
67+
github.com/prometheus/client_model v0.6.1 // indirect
68+
github.com/prometheus/common v0.62.0 // indirect
69+
github.com/prometheus/procfs v0.15.1 // indirect
70+
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
6371
github.com/sirupsen/logrus v1.9.3 // indirect
64-
github.com/vbatts/tar-split v0.11.3 // indirect
65-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.0 // indirect
66-
go.opentelemetry.io/otel v1.20.0 // indirect
67-
go.opentelemetry.io/otel/metric v1.20.0 // indirect
68-
go.opentelemetry.io/otel/trace v1.20.0 // indirect
69-
go.uber.org/multierr v1.11.0 // indirect
70-
go.uber.org/zap v1.26.0 // indirect
71-
golang.org/x/crypto v0.21.0 // indirect
72-
golang.org/x/net v0.23.0 // indirect
73-
golang.org/x/oauth2 v0.14.0 // indirect
74-
golang.org/x/sync v0.4.0 // indirect
75-
golang.org/x/sys v0.18.0 // indirect
76-
golang.org/x/text v0.14.0 // indirect
77-
google.golang.org/appengine v1.6.8 // indirect
78-
google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405 // indirect
79-
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect
80-
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
81-
google.golang.org/grpc v1.59.0 // indirect
82-
google.golang.org/protobuf v1.33.0 // indirect
83-
gopkg.in/inf.v0 v0.9.1 // indirect
84-
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
85-
gopkg.in/yaml.v2 v2.4.0 // indirect
86-
k8s.io/api v0.28.4 // indirect
87-
k8s.io/apimachinery v0.28.4 // indirect
88-
k8s.io/klog/v2 v2.100.1 // indirect
89-
k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect
90-
knative.dev/pkg v0.0.0-20231101193506-b09d4f2a2845 // indirect
91-
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
92-
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
72+
github.com/skeema/knownhosts v1.3.1 // indirect
73+
github.com/vbatts/tar-split v0.12.1 // indirect
74+
github.com/xanzy/ssh-agent v0.3.3 // indirect
75+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
76+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 // indirect
77+
go.opentelemetry.io/otel v1.34.0 // indirect
78+
go.opentelemetry.io/otel/metric v1.34.0 // indirect
79+
go.opentelemetry.io/otel/sdk v1.34.0 // indirect
80+
go.opentelemetry.io/otel/trace v1.34.0 // indirect
81+
golang.org/x/crypto v0.33.0 // indirect
82+
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa // indirect
83+
golang.org/x/net v0.35.0 // indirect
84+
golang.org/x/oauth2 v0.26.0 // indirect
85+
golang.org/x/sync v0.11.0 // indirect
86+
golang.org/x/sys v0.30.0 // indirect
87+
golang.org/x/text v0.22.0 // indirect
88+
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
89+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect
90+
google.golang.org/grpc v1.70.0 // indirect
91+
google.golang.org/protobuf v1.36.5 // indirect
92+
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
93+
gopkg.in/warnings.v0 v0.1.2 // indirect
94+
gopkg.in/yaml.v3 v3.0.1 // indirect
95+
k8s.io/apimachinery v0.32.2 // indirect
9396
)

0 commit comments

Comments
 (0)