Skip to content

Commit

Permalink
Create read-only user for bare metal mirror instance
Browse files Browse the repository at this point in the history
Create a read-only user for berlin baremetal instance with read access
to the advertisement mirror stored at s3.
  • Loading branch information
masih committed Feb 12, 2024
1 parent ac1a1bc commit 4e6cab1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
5 changes: 5 additions & 0 deletions deploy/infrastructure/prod/us-east-2/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ locals {

iam_path = "/${local.environment_name}/${local.region}/"

# Base64 encoded GPG public key used to encrypt the password and secret access key of IAM users
# created for common use, such as pl-grafana and github_mgmt.
# The private key is stored at `storetheidnex` 1Password vault.
pgp_key = "mQINBGJZ1H8BEAC8xD5cvpW+E/nyddmzgZ70HC3CYcveiVU1IdVJajf0lKwMh8Hbvg++zdh48ZFvyx/phHPl1/m2yW0zl7VIsV8ppzezd1FitG0MGFv4GOBMlrTwRK8LBxTVrBRpxi1LefCnSpc5d9CIrzMVCBN2fnA7OTYhNE7t72OUythuSoDHKoxB8rWEY6xdJaTjmCyx2rY+TP/Iygo0yLO7gHmvHdCCPCtgOYV6cecMX48d4j45hTQ57p7nNF0kPgt2k5wbm0K/eko1ApKGsf2rGji2xfWdo4BIDwIHmMzeTxipMzGq3fOQhYP/pfB5KijPnqPghNmIkpD7FpwlPRyI3zeYU8kzyw+RLyQl/iWc9h9Y/z9PHun8em4pHhtVDVBb6kw/tjXBvw1KDkZZsR8DaBkasIJ6esdgfzWGRDh4uX2OlbY093xI1JreviPeryIB3tG7vmCQFBWydvQm5gacnivQkae+VyN90Z41msRI4vWgfGMjIiEcsLOs2/ksOCQdri7kffxKmWGOBjjEMHsC5JpnPTX54sQdVO+I2R7KAo/5qQql2YWmh0eg1E5tTO2XcuIIgG545kAzOr8y1vmQ8/QUDx6kWFPY2JX+Cu9NFhTFQQuk1LMzPSI1Ed13kjh3m5+2w6pkJcdGN/bWF6Ab8R0crDtrASv83iCoraroB+v/4acrMwARAQABtB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W2Z0HqpVjT5lr16w5j9VYtTKEXvSo6/zieW72D+j/LngyPiFTQjTDBl9BObgs2xka7HAZGM0X1FXstxgtB8vyOJZ4JGevN2OflLNnyGtOwy0hA2UO1tevQp0ALk3amyfNqNusyVIt7vqg2GGJgjaa"

tags = {
"Environment" = local.environment_name
"ManagedBy" = "terraform"
Expand Down
8 changes: 6 additions & 2 deletions deploy/infrastructure/prod/us-east-2/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ output "prod_cid_contact_nameservers" {
value = aws_route53_zone.prod_external.name_servers
}

output "prod_cid_contact_zone_id" {
value = aws_route53_zone.prod_external.zone_id
output "berg_user_access_key_id" {
value = module.berg_user.iam_access_key_id
}

output "berg_user_access_key_secret_encrypted" {
value = module.berg_user.iam_access_key_encrypted_secret
}
36 changes: 36 additions & 0 deletions deploy/infrastructure/prod/us-east-2/s3_adstore_berg.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
locals {
berg_username = "berg"
}

module "berg_user" {
source = "registry.terraform.io/terraform-aws-modules/iam/aws//modules/iam-user"
version = "5.20.0"

name = local.berg_username
pgp_key = local.pgp_key
create_iam_user_login_profile = false
create_iam_access_key = true
}

data "aws_iam_policy_document" "berg_s3_ro" {
statement {
effect = "Allow"

actions = [
"s3:GetObject",
"s3:ListBucket",
]

resources = [aws_s3_bucket.sti_s3_adstore.arn, "${aws_s3_bucket.sti_s3_adstore.arn}/*"]
}
}

resource "aws_iam_policy" "berg_s3_ro" {
name = "${local.environment_name}_berg_s3_ro"
policy = data.aws_iam_policy_document.berg_s3_ro.json
}

resource "aws_iam_user_policy_attachment" "berg_s3_ro" {
policy_arn = aws_iam_policy.berg_s3_ro.arn
user = local.berg_username
}

0 comments on commit 4e6cab1

Please sign in to comment.