|
3 | 3 | This component is responsible for provisioning user and system IAM roles outside the `identity` account. |
4 | 4 | It sets them up to be assumed from the "team" roles defined in the `identity` account by |
5 | 5 | [the `aws-teams` component](../aws-teams) and/or the AWS SSO permission sets |
6 | | -defined in [the `aws-sso` component](../aws-sso). |
| 6 | +defined in [the `aws-sso` component](../aws-sso), and/or be directly accessible via SAML logins. |
| 7 | + |
| 8 | + |
| 9 | +### Privileges are Granted to Users via IAM Policies |
| 10 | + |
| 11 | +Each role is granted permissions by attaching a list of IAM policies to the IAM role |
| 12 | +via its `role_policy_arns` list. You can configure AWS managed policies by entering the ARNs of the policies |
| 13 | +directly into the list, or you can create a custom policy as follows: |
| 14 | + |
| 15 | +1. Give the policy a name, e.g. `eks-admin`. We will use `NAME` as a placeholder for the name in the instructions below. |
| 16 | +2. Create a file in the `aws-teams` directory with the name `policy-NAME.tf`. |
| 17 | +3. In that file, create a policy as follows: |
| 18 | + |
| 19 | + ```hcl |
| 20 | + data "aws_iam_policy_document" "NAME" { |
| 21 | + # Define the policy here |
| 22 | + } |
| 23 | +
|
| 24 | + resource "aws_iam_policy" "NAME" { |
| 25 | + name = format("%s-NAME", module.this.id) |
| 26 | + policy = data.aws_iam_policy_document.NAME.json |
| 27 | +
|
| 28 | + tags = module.this.tags |
| 29 | + } |
| 30 | + ``` |
| 31 | +
|
| 32 | +4. Create a file named `additional-policy-map_override.tf` in the `aws-team-roles` directory (if it does not already exist). |
| 33 | + This is a [terraform override file](https://developer.hashicorp.com/terraform/language/files/override), meaning its |
| 34 | + contents will be merged with the main terraform file, and any locals defined in it will override locals defined in other files. |
| 35 | + Having your code in this separate override file makes it possible for the component to provide a placeholder local variable |
| 36 | + so that it works without customization, while allowing you to customize the component and still update it without losing your customizations. |
| 37 | +5. In that file, redefine the local variable `overridable_additional_custom_policy_map` map as follows: |
| 38 | +
|
| 39 | + ```hcl |
| 40 | + locals { |
| 41 | + overridable_additional_custom_policy_map = { |
| 42 | + NAME = aws_iam_policy.NAME.arn |
| 43 | + } |
| 44 | + } |
| 45 | + ``` |
| 46 | +
|
| 47 | + If you have multiple custom policies, add each one to the map in the form `NAME = aws_iam_policy.NAME.arn`. |
| 48 | +6. With that done, you can now attach that policy by adding the name to the `role_policy_arns` list. For example: |
| 49 | +
|
| 50 | + ```yaml |
| 51 | + role_policy_arns: |
| 52 | + - "arn:aws:iam::aws:policy/job-function/ViewOnlyAccess" |
| 53 | + - "NAME" |
| 54 | + ``` |
| 55 | +
|
| 56 | +
|
7 | 57 |
|
8 | 58 | ## Usage |
9 | 59 |
|
|
0 commit comments