Skip to content

Commit 314acee

Browse files
Chris EveryjvmOVO
Chris Every
andauthored
unhardcodes region in aws module. allows user to specify their own region but defaults to eu-west-1 if not set (#341)
Co-authored-by: Josh Merritt <[email protected]>
1 parent 1cabdc5 commit 314acee

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

tf_module/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ module "cloud-key-rotator" {
4444
* (Optional) `config_data = <string>` -> Pass a json blob from any source containing your config file.
4545
* (Optional) `enable_ssm_location = false` -> Whether to create an IAM policy allowing `ssm:PutParameter`.
4646
Set this to `true` if using SSM as a `cloud-key-rotator` location.
47+
* (Optional) `region = <string>` -> pass aws region. Defaults to `eu-west-1` if not set.
4748

4849
## Usage - GCP
4950

@@ -95,7 +96,7 @@ EOF
9596
service account and scheduler job names to prevent naming conflicts
9697
* (Optional) `ckr_schedule = "0 10 * * 1-5"` -> Defaults to triggering 10am Monday-Friday.
9798
* (Optional) `ckr_schedule_time_zone = "Europe/London"` -> The time zone for the scheduler job. Defaults to Europe/London
98-
* (Optional) `deploying_accounts = ["serviceAccount:[email protected]"]` -> Any accounts which
99-
will be deploying the CKR terraform but do not have the iam.serviceAccountUser permission for the whole project. This
100-
gives the supplied accounts iam.serviceAccountUser permissions for the Cloud Key Rotator service account which is
99+
* (Optional) `deploying_accounts = ["serviceAccount:[email protected]"]` -> Any accounts which
100+
will be deploying the CKR terraform but do not have the iam.serviceAccountUser permission for the whole project. This
101+
gives the supplied accounts iam.serviceAccountUser permissions for the Cloud Key Rotator service account which is
101102
necessary to deploy the terraform module. Defaults to an empty list

tf_module/ckr_aws/main.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ resource "aws_iam_policy" "ckr_log_policy" {
119119
"logs:PutLogEvents"
120120
],
121121
"Resource": [
122-
"arn:aws:logs:eu-west-1:${local.account_id}:log-stream:*:*:*",
123-
"arn:aws:logs:eu-west-1:${local.account_id}:log-group:/aws/lambda/cloud-key-*"
122+
"arn:aws:logs:${var.region}:${local.account_id}:log-stream:*:*:*",
123+
"arn:aws:logs:${var.region}:${local.account_id}:log-group:/aws/lambda/cloud-key-*"
124124
]
125125
},
126126
{
127127
"Effect": "Allow",
128128
"Action": "logs:CreateLogGroup",
129-
"Resource": "arn:aws:logs:eu-west-1:${local.account_id}:*"
129+
"Resource": "arn:aws:logs:${var.region}:${local.account_id}:*"
130130
}
131131
]
132132
}
@@ -150,7 +150,7 @@ resource "aws_iam_policy" "ckr_ssm_policy" {
150150
"ssm:PutParameter"
151151
],
152152
"Resource": [
153-
"arn:aws:ssm:eu-west-1:${local.account_id}:parameter/*"
153+
"arn:aws:ssm:${var.region}:${local.account_id}:parameter/*"
154154
]
155155
}
156156
]

tf_module/ckr_aws/vars.tf

+5
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ variable "enable_ssm_location" {
1717
variable "ckr_trigger_description" {
1818
default = "Scheduled cloud key rotation"
1919
}
20+
21+
variable "region" {
22+
type = string
23+
default = "eu-west-1"
24+
}

0 commit comments

Comments
 (0)