Skip to content

Commit

Permalink
unhardcodes region in aws module. allows user to specify their own re…
Browse files Browse the repository at this point in the history
…gion but defaults to eu-west-1 if not set (#341)

Co-authored-by: Josh Merritt <[email protected]>
  • Loading branch information
Chris Every and jvmOVO authored Mar 25, 2021
1 parent 1cabdc5 commit 314acee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
7 changes: 4 additions & 3 deletions tf_module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module "cloud-key-rotator" {
* (Optional) `config_data = <string>` -> Pass a json blob from any source containing your config file.
* (Optional) `enable_ssm_location = false` -> Whether to create an IAM policy allowing `ssm:PutParameter`.
Set this to `true` if using SSM as a `cloud-key-rotator` location.
* (Optional) `region = <string>` -> pass aws region. Defaults to `eu-west-1` if not set.

## Usage - GCP

Expand Down Expand Up @@ -95,7 +96,7 @@ EOF
service account and scheduler job names to prevent naming conflicts
* (Optional) `ckr_schedule = "0 10 * * 1-5"` -> Defaults to triggering 10am Monday-Friday.
* (Optional) `ckr_schedule_time_zone = "Europe/London"` -> The time zone for the scheduler job. Defaults to Europe/London
* (Optional) `deploying_accounts = ["serviceAccount:[email protected]"]` -> Any accounts which
will be deploying the CKR terraform but do not have the iam.serviceAccountUser permission for the whole project. This
gives the supplied accounts iam.serviceAccountUser permissions for the Cloud Key Rotator service account which is
* (Optional) `deploying_accounts = ["serviceAccount:[email protected]"]` -> Any accounts which
will be deploying the CKR terraform but do not have the iam.serviceAccountUser permission for the whole project. This
gives the supplied accounts iam.serviceAccountUser permissions for the Cloud Key Rotator service account which is
necessary to deploy the terraform module. Defaults to an empty list
8 changes: 4 additions & 4 deletions tf_module/ckr_aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ resource "aws_iam_policy" "ckr_log_policy" {
"logs:PutLogEvents"
],
"Resource": [
"arn:aws:logs:eu-west-1:${local.account_id}:log-stream:*:*:*",
"arn:aws:logs:eu-west-1:${local.account_id}:log-group:/aws/lambda/cloud-key-*"
"arn:aws:logs:${var.region}:${local.account_id}:log-stream:*:*:*",
"arn:aws:logs:${var.region}:${local.account_id}:log-group:/aws/lambda/cloud-key-*"
]
},
{
"Effect": "Allow",
"Action": "logs:CreateLogGroup",
"Resource": "arn:aws:logs:eu-west-1:${local.account_id}:*"
"Resource": "arn:aws:logs:${var.region}:${local.account_id}:*"
}
]
}
Expand All @@ -150,7 +150,7 @@ resource "aws_iam_policy" "ckr_ssm_policy" {
"ssm:PutParameter"
],
"Resource": [
"arn:aws:ssm:eu-west-1:${local.account_id}:parameter/*"
"arn:aws:ssm:${var.region}:${local.account_id}:parameter/*"
]
}
]
Expand Down
5 changes: 5 additions & 0 deletions tf_module/ckr_aws/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ variable "enable_ssm_location" {
variable "ckr_trigger_description" {
default = "Scheduled cloud key rotation"
}

variable "region" {
type = string
default = "eu-west-1"
}

0 comments on commit 314acee

Please sign in to comment.