Skip to content

Commit a935990

Browse files
authored
add mixins, update docs (#33)
* add mixins, update docs * versions.tf
1 parent 26a7003 commit a935990

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

README.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@ description: |-
77
This utilizes
88
[the roles-to-principals submodule](https://github.com/cloudposse/terraform-aws-components/tree/main/modules/account-map/modules/roles-to-principals)
99
to assign accounts to various roles. It is also compatible with the
10-
[GitHub Actions IAM Role mixin](https://github.com/cloudposse/terraform-aws-components/blob/master/mixins/github-actions-iam-role/README-github-action-iam-role.md).
10+
[GitHub Actions IAM Role mixin](https://github.com/cloudposse-terraform-components/mixins/blob/main/src/mixins/github-actions-iam-role/README-github-action-iam-role.md).
11+
12+
<details>
13+
<summary>Warning (Older) regarding <code>eks-iam</code> component </summary>
1114
1215
> [!WARNING]
1316
>
1417
> Older versions of our reference architecture have an`eks-iam` component that needs to be updated to provide sufficient
1518
> IAM roles to allow pods to pull from ECR repos
1619
20+
</details>
21+
1722
## Usage
1823
1924
**Stack Level**: Regional

mixins/DO_NOT_VENDOR_versions.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# DO NOT VENDOR THIS FILE
2+
# This file is used to satisfy the tests of this repository and should not be vendored.
3+
terraform {
4+
required_version = ">= 1.0.0"
5+
6+
required_providers {
7+
aws = {
8+
source = "hashicorp/aws"
9+
version = ">= 4.9.0"
10+
}
11+
}
12+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
locals {
2+
github_actions_iam_policy = data.aws_iam_policy_document.github_actions_iam_policy.json
3+
ecr_resources_static = [for k, v in module.ecr.repository_arn_map : v]
4+
ecr_resources_wildcard = [for k, v in module.ecr.repository_arn_map : "${v}/*"]
5+
resources = concat(local.ecr_resources_static, local.ecr_resources_wildcard)
6+
}
7+
8+
data "aws_iam_policy_document" "github_actions_iam_policy" {
9+
statement {
10+
sid = "AllowECRPermissions"
11+
effect = "Allow"
12+
actions = [
13+
"ecr:BatchCheckLayerAvailability",
14+
"ecr:BatchDeleteImage",
15+
"ecr:BatchGetImage",
16+
"ecr:CompleteLayerUpload",
17+
"ecr:DeleteLifecyclePolicy",
18+
"ecr:DescribeImages",
19+
"ecr:DescribeImageScanFindings",
20+
"ecr:DescribeRepositories",
21+
"ecr:GetAuthorizationToken",
22+
"ecr:GetDownloadUrlForLayer",
23+
"ecr:GetLifecyclePolicy",
24+
"ecr:GetLifecyclePolicyPreview",
25+
"ecr:GetRepositoryPolicy",
26+
"ecr:InitiateLayerUpload",
27+
"ecr:ListImages",
28+
"ecr:PutImage",
29+
"ecr:PutImageScanningConfiguration",
30+
"ecr:PutImageTagMutability",
31+
"ecr:PutLifecyclePolicy",
32+
"ecr:StartImageScan",
33+
"ecr:StartLifecyclePolicyPreview",
34+
"ecr:TagResource",
35+
"ecr:UntagResource",
36+
"ecr:UploadLayerPart",
37+
]
38+
resources = local.resources
39+
}
40+
41+
# required as minimum permissions for pushing and logging into a public ECR repository
42+
# https://github.com/aws-actions/amazon-ecr-login#permissions
43+
# https://docs.aws.amazon.com/AmazonECR/latest/public/docker-push-ecr-image.html
44+
statement {
45+
sid = "AllowEcrGetAuthorizationToken"
46+
effect = "Allow"
47+
actions = [
48+
"ecr:GetAuthorizationToken",
49+
"sts:GetServiceBearerToken"
50+
]
51+
resources = ["*"]
52+
}
53+
}

0 commit comments

Comments
 (0)