Skip to content

Commit a6cf85e

Browse files
committed
move iam resource
1 parent 7f11a11 commit a6cf85e

4 files changed

Lines changed: 29 additions & 27 deletions

File tree

infrastructure/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177

178178
| Name | Type |
179179
|------|------|
180+
| [aws_api_gateway_account.logging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_account) | resource |
180181
| [aws_api_gateway_api_key.api_key_pdm](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_api_key) | resource |
181182
| [aws_api_gateway_api_key.apim](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_api_key) | resource |
182183
| [aws_api_gateway_authorizer.repo_authoriser](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_authorizer) | resource |
@@ -258,6 +259,7 @@
258259
| [aws_iam_policy.ses_send_email_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
259260
| [aws_iam_policy.ssm_access_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
260261
| [aws_iam_policy.ssm_access_policy_authoriser](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
262+
| [aws_iam_role.api_gateway_cloudwatch](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
261263
| [aws_iam_role.cognito_unauthenticated](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
262264
| [aws_iam_role.create_post_presign_url_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
263265
| [aws_iam_role.cross_account_backup_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
@@ -270,6 +272,7 @@
270272
| [aws_iam_role.splunk_sqs_forwarder](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
271273
| [aws_iam_role.stitch_presign_url_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
272274
| [aws_iam_role_policy.splunk_access_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
275+
| [aws_iam_role_policy_attachment.api_gateway_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
273276
| [aws_iam_role_policy_attachment.backup_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
274277
| [aws_iam_role_policy_attachment.cloudwatch_rum_cognito_unauth](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
275278
| [aws_iam_role_policy_attachment.create_post_presign_url](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |

infrastructure/iam.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,29 @@ resource "aws_iam_role_policy_attachment" "ods_report_presign_url" {
193193
role = aws_iam_role.ods_report_presign_url_role.name
194194
policy_arn = aws_iam_policy.s3_document_data_policy_for_ods_report_lambda.arn
195195
}
196+
197+
resource "aws_iam_role" "api_gateway_cloudwatch" {
198+
name = "${terraform.workspace}_DocStoreAPIGatewayLogs"
199+
200+
assume_role_policy = jsonencode({
201+
Version = "2012-10-17"
202+
Statement = [
203+
{
204+
Action = "sts:AssumeRole"
205+
Effect = "Allow"
206+
Principal = {
207+
Service = "apigateway.amazonaws.com"
208+
}
209+
},
210+
]
211+
})
212+
}
213+
214+
resource "aws_iam_role_policy_attachment" "api_gateway_logs" {
215+
role = aws_iam_role.api_gateway_cloudwatch.name
216+
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs"
217+
}
218+
219+
resource "aws_api_gateway_account" "logging" {
220+
cloudwatch_role_arn = aws_iam_role.api_gateway_cloudwatch.arn
221+
}

infrastructure/modules/gateway/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@ No modules.
1818

1919
| Name | Type |
2020
|------|------|
21-
| [aws_api_gateway_account.logging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_account) | resource |
2221
| [aws_api_gateway_integration.preflight_integration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_integration) | resource |
2322
| [aws_api_gateway_integration_response.preflight_integration_response](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_integration_response) | resource |
2423
| [aws_api_gateway_method.preflight_method](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method) | resource |
2524
| [aws_api_gateway_method.proxy_method](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method) | resource |
2625
| [aws_api_gateway_method_response.preflight_method_response](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method_response) | resource |
2726
| [aws_api_gateway_resource.gateway_resource](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_resource) | resource |
28-
| [aws_iam_role.api_gateway_cloudwatch](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
29-
| [aws_iam_role_policy_attachment.api_gateway_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
3027

3128
## Inputs
3229

infrastructure/modules/gateway/main.tf

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,4 @@ resource "aws_api_gateway_integration_response" "preflight_integration_response"
6969
depends_on = [aws_api_gateway_method_response.preflight_method_response, aws_api_gateway_resource.gateway_resource]
7070
}
7171

72-
resource "aws_iam_role" "api_gateway_cloudwatch" {
73-
name = "${terraform.workspace}_DocStoreAPIGatewayLogs"
7472

75-
assume_role_policy = jsonencode({
76-
Version = "2012-10-17"
77-
Statement = [
78-
{
79-
Action = "sts:AssumeRole"
80-
Effect = "Allow"
81-
Principal = {
82-
Service = "apigateway.amazonaws.com"
83-
}
84-
},
85-
]
86-
})
87-
}
88-
89-
resource "aws_iam_role_policy_attachment" "api_gateway_logs" {
90-
role = aws_iam_role.api_gateway_cloudwatch.name
91-
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs"
92-
}
93-
94-
resource "aws_api_gateway_account" "logging" {
95-
cloudwatch_role_arn = aws_iam_role.api_gateway_cloudwatch.arn
96-
}

0 commit comments

Comments
 (0)