You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Terraform module that performs a local docker pull and push to a given AWS ECR repository
4
+
5
+
## Use Case
6
+
In late 2020, Docker Hub announced that the Hub service would begin limiting the rate at which images can be pulled under their anonymous and free plans.
7
+
8
+
The [AWS recommendation](https://aws.amazon.com/blogs/containers/advice-for-customers-dealing-with-docker-hub-rate-limits-and-a-coming-soon-announcement/) for those not wishing to upgrade to a paid plan is to mirror the Dockerhub image to their own AWS ECR repository.
9
+
10
+
This simple task requires a basic 'pull from Dockerhub-push to ECR' loop for which there exists no simple bootstrapping solution. The typical use case is a new ECR repository that would look to use a Dockerhub image as its 'base' image which can then be used in subsequent builds without the pull limits.
11
+
12
+
This module is a simple terraform `local-exec` provisioner which runs the required awscli and docker push commands to ECR, and can be woven in to your existing set-up.
13
+
14
+
## Requirements
15
+
16
+
- aws-cli v2 installed and configured with a named [profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) that has permissions to push to the desired ECR repository
17
+
-[Docker installed](https://docs.docker.com/engine/install/) on the machine executing terraform, and permissions for the user executing terraform to run docker commands (e.g. by adding the user to the 'docker' user group)
18
+
- Experimental mode enabled if you wish to use `architecture` argument. See [Leverage multi-CPU architecture support](https://docs.docker.com/desktop/multi-arch/) in Docker documentation.
19
+
20
+
## Idempotence
21
+
22
+
As this module is essentially running a series of bash commands, it ensures idempotence by triggering only when any of the values of the `docker_source`, `ecr_repo_name` or `ecr_repo_tag` variables are changed.
23
+
24
+
## Usage Example
25
+
26
+
```
27
+
module "ecr_mirror" {
28
+
source = "TechToSpeech/ecr-mirror/aws"
29
+
version = "0.0.8"
30
+
architecture = "linux/arm64/v8"
31
+
aws_account_id = "123456544225"
32
+
aws_region = "eu-west-1"
33
+
docker_source = "wordpress:php7.4-apache"
34
+
aws_profile = "default"
35
+
ecr_repo_name = "php_wordpress"
36
+
ecr_repo_tag = "base"
37
+
}
38
+
```
39
+
40
+
Consider adding an additional `depends_on` attribute if you are using this module in combination with a Terraform resource that also creates the ECR repository being pushed to.
41
+
42
+
## License
43
+
Licensed under the Apache License, Version 2.0 (the "License").
44
+
45
+
You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0.
46
+
47
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, without WARRANTIES or conditions of any kind, either express or implied.
48
+
49
+
See the License for the specific language governing permissions and limitations under the License.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
# Changelog
2
2
3
+
## 0.0.8
4
+
5
+
Added support for overriding the desired platform architecture of the docker image. (Note: Experimental mode must be enabled on your local docker client)
Copy file name to clipboardExpand all lines: README.md
+82-1Lines changed: 82 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,8 @@ As this module is essentially running a series of bash commands, it ensures idem
25
25
```
26
26
module "ecr_mirror" {
27
27
source = "TechToSpeech/ecr-mirror/aws"
28
+
version = "0.0.8"
29
+
architecture = "linux/arm64/v8"
28
30
aws_account_id = "123456544225"
29
31
aws_region = "eu-west-1"
30
32
docker_source = "wordpress:php7.4-apache"
@@ -43,4 +45,83 @@ You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0.
43
45
44
46
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, without WARRANTIES or conditions of any kind, either express or implied.
45
47
46
-
See the License for the specific language governing permissions and limitations under the License.
48
+
See the License for the specific language governing permissions and limitations under the License.
49
+
<!-- BEGIN_TF_DOCS -->
50
+
# Terraform Module: AWS ECR Mirror
51
+
52
+
A Terraform module that performs a local docker pull and push to a given AWS ECR repository
53
+
54
+
## Use Case
55
+
In late 2020, Docker Hub announced that the Hub service would begin limiting the rate at which images can be pulled under their anonymous and free plans.
56
+
57
+
The [AWS recommendation](https://aws.amazon.com/blogs/containers/advice-for-customers-dealing-with-docker-hub-rate-limits-and-a-coming-soon-announcement/) for those not wishing to upgrade to a paid plan is to mirror the Dockerhub image to their own AWS ECR repository.
58
+
59
+
This simple task requires a basic 'pull from Dockerhub-push to ECR' loop for which there exists no simple bootstrapping solution. The typical use case is a new ECR repository that would look to use a Dockerhub image as its 'base' image which can then be used in subsequent builds without the pull limits.
60
+
61
+
This module is a simple terraform `local-exec` provisioner which runs the required awscli and docker push commands to ECR, and can be woven in to your existing set-up.
62
+
63
+
## Requirements
64
+
65
+
- aws-cli v2 installed and configured with a named [profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) that has permissions to push to the desired ECR repository
66
+
-[Docker installed](https://docs.docker.com/engine/install/) on the machine executing terraform, and permissions for the user executing terraform to run docker commands (e.g. by adding the user to the 'docker' user group)
67
+
- Experimental mode enabled if you wish to use `architecture` argument. See [Leverage multi-CPU architecture support](https://docs.docker.com/desktop/multi-arch/) in Docker documentation.
68
+
69
+
## Idempotence
70
+
71
+
As this module is essentially running a series of bash commands, it ensures idempotence by triggering only when any of the values of the `docker_source`, `ecr_repo_name` or `ecr_repo_tag` variables are changed.
72
+
73
+
## Usage Example
74
+
75
+
```
76
+
module "ecr_mirror" {
77
+
source = "TechToSpeech/ecr-mirror/aws"
78
+
version = "0.0.8"
79
+
architecture = "linux/arm64/v8"
80
+
aws_account_id = "123456544225"
81
+
aws_region = "eu-west-1"
82
+
docker_source = "wordpress:php7.4-apache"
83
+
aws_profile = "default"
84
+
ecr_repo_name = "php_wordpress"
85
+
ecr_repo_tag = "base"
86
+
}
87
+
```
88
+
89
+
Consider adding an additional `depends_on` attribute if you are using this module in combination with a Terraform resource that also creates the ECR repository being pushed to.
90
+
91
+
## License
92
+
Licensed under the Apache License, Version 2.0 (the "License").
93
+
94
+
You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0.
95
+
96
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, without WARRANTIES or conditions of any kind, either express or implied.
97
+
98
+
See the License for the specific language governing permissions and limitations under the License.
99
+
100
+
## Inputs
101
+
102
+
| Name | Description | Type | Default | Required |
| <aname="input_architecture"></a> [architecture](#input\_architecture)| The override flag to pull an image of a specific architecture. e.g. `linux/arm64/v8`|`string`|`""`| no |
105
+
| <aname="input_aws_account_id"></a> [aws\_account\_id](#input\_aws\_account\_id)| The AWS Account ID where the ECR repository is located. |`any`| n/a | yes |
106
+
| <aname="input_aws_profile"></a> [aws\_profile](#input\_aws\_profile)| The awscli profile name (located in the ~/.aws/credentials file) used to authenticate the ECR login and push (Optional) |`string`|`""`| no |
107
+
| <aname="input_aws_region"></a> [aws\_region](#input\_aws\_region)| The region in which the ECR repository is located. |`any`| n/a | yes |
108
+
| <aname="input_docker_source"></a> [docker\_source](#input\_docker\_source)| The source location of the Docker image being pulled. |`any`| n/a | yes |
109
+
| <aname="input_ecr_repo_name"></a> [ecr\_repo\_name](#input\_ecr\_repo\_name)| The name of the ECR repository being pushed to. |`any`| n/a | yes |
110
+
| <aname="input_ecr_repo_tag"></a> [ecr\_repo\_tag](#input\_ecr\_repo\_tag)| The tag of the ECR repository image being pushed. |`any`| n/a | yes |
111
+
## Modules
112
+
113
+
No modules.
114
+
## Outputs
115
+
116
+
| Name | Description |
117
+
|------|-------------|
118
+
| <aname="output_ecr_repo_arn"></a> [ecr\_repo\_arn](#output\_ecr\_repo\_arn)| The repository URL with tag of the pushed image. |
0 commit comments