Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring AWS Managed policies #100

Merged
merged 3 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modules/adot/adot.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ module "adot_collector" {
role_name = local.role_name
provider_url = data.aws_eks_cluster.this.identity[0].oidc[0].issuer
role_policy_arns = [
"arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy",
"arn:aws:iam::aws:policy/AmazonPrometheusRemoteWriteAccess",
"arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess"
data.aws_iam_policy.cloudwatch_agent_server.arn,
data.aws_iam_policy.amp_remote_write_access.arn,
data.aws_iam_policy.xray_write_access.arn
]
oidc_fully_qualified_subjects = ["system:serviceaccount:${var.namespace}:${var.service_account}"]

Expand Down
12 changes: 12 additions & 0 deletions modules/adot/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@
data "aws_eks_cluster" "this" {
name = var.cluster_name
}

data "aws_iam_policy" "cloudwatch_agent_server" {
arn = "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"
}

data "aws_iam_policy" "amp_remote_write_access" {
arn = "arn:aws:iam::aws:policy/AmazonPrometheusRemoteWriteAccess"
}

data "aws_iam_policy" "xray_write_access" {
arn = "arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess"
}
5 changes: 2 additions & 3 deletions modules/grafana/grafana.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ module "grafana_role" {
role_name = local.role_name
provider_url = data.aws_eks_cluster.this.identity[0].oidc[0].issuer
role_policy_arns = [
aws_iam_policy.grafana.arn,
data.aws_iam_policy.cloudwatch_readonly_access,
data.aws_iam_policy.timestream_readonly_access
data.aws_iam_policy.cloudwatch_readonly_access.arn,
data.aws_iam_policy.timestream_readonly_access.arn
]
oidc_fully_qualified_subjects = ["system:serviceaccount:${var.namespace}:${var.service_account}"]
tags = merge(
Expand Down
1 change: 1 addition & 0 deletions modules/mimir/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Terraform module which configure Grafana Mimir resources on Amazon AWS
| [aws_kms_alias.mimir](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_alias) | resource |
| [aws_kms_key.mimir](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |
| [aws_eks_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source |
| [aws_iam_policy.amp_remote_write_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source |
| [aws_iam_policy_document.bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.kms](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |

Expand Down
4 changes: 4 additions & 0 deletions modules/mimir/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
data "aws_eks_cluster" "this" {
name = var.cluster_name
}

data "aws_iam_policy" "amp_remote_write_access" {
arn = "arn:aws:iam::aws:policy/AmazonPrometheusRemoteWriteAccess"
}
2 changes: 2 additions & 0 deletions modules/mimir/mimir.tf
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ module "mimir_role" {
role_policy_arns = var.enable_kms ? [
aws_iam_policy.bucket.arn,
aws_iam_policy.kms[0].arn,
data.aws_iam_policy.amp_remote_write_access.arn
] : [
aws_iam_policy.bucket.arn,
data.aws_iam_policy.amp_remote_write_access.arn
]
oidc_fully_qualified_subjects = ["system:serviceaccount:${var.namespace}:${var.service_account}"]
tags = merge(
Expand Down
5 changes: 3 additions & 2 deletions modules/prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ tags = {

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.12.1 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.0.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_prometheus_role"></a> [prometheus\_role](#module\_prometheus\_role) | terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc | 5.2.0 |
| <a name="module_prometheus_role"></a> [prometheus\_role](#module\_prometheus\_role) | terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc | 5.5.0 |

## Resources

Expand All @@ -72,6 +72,7 @@ tags = {
| [aws_iam_policy.bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_policy.kms](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_eks_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source |
| [aws_iam_policy.amp_remote_write_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source |
| [aws_iam_policy_document.bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.kms](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_kms_key.thanos](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/kms_key) | data source |
Expand Down
4 changes: 4 additions & 0 deletions modules/prometheus/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ data "aws_kms_key" "thanos" {
data "aws_eks_cluster" "this" {
name = var.cluster_name
}

data "aws_iam_policy" "amp_remote_write_access" {
arn = "arn:aws:iam::aws:policy/AmazonPrometheusRemoteWriteAccess"
}
2 changes: 2 additions & 0 deletions modules/prometheus/prometheus.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ module "prometheus_role" {
role_policy_arns = var.enable_kms ? [
aws_iam_policy.bucket.arn,
aws_iam_policy.kms[0].arn,
data.aws_iam_policy.amp_remote_write_access.arn
] : [
aws_iam_policy.bucket.arn,
data.aws_iam_policy.amp_remote_write_access.arn
]
oidc_fully_qualified_subjects = ["system:serviceaccount:${var.namespace}:${var.service_account}"]
tags = merge(
Expand Down