Skip to content

Commit

Permalink
Remove deployer dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
pjuniorlima committed Mar 10, 2022
1 parent 785d7bc commit c77b03e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 61 deletions.
28 changes: 0 additions & 28 deletions site-main/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -121,34 +121,6 @@ resource "aws_s3_bucket_public_access_block" "this" {
// target_prefix = "${var.log_bucket_prefix}"
// }

################################################################################################################
## Configure the credentials and access to the bucket for a deployment user
################################################################################################################
data "template_file" "deployer_role_policy_file" {
template = file("${path.module}/deployer_role_policy.json")

vars = {
bucket = var.bucket_name
}
}

resource "aws_iam_policy" "site_deployer_policy" {
count = var.deployer != null ? 1 : 0

name = "${var.bucket_name}.deployer"
path = "/"
description = "Policy allowing to publish a new version of the website to the S3 bucket"
policy = data.template_file.deployer_role_policy_file.rendered
}

resource "aws_iam_policy_attachment" "site-deployer-attach-user-policy" {
count = var.deployer != null ? 1 : 0

name = "${var.bucket_name}-deployer-policy-attachment"
users = [var.deployer]
policy_arn = aws_iam_policy.site_deployer_policy.0.arn
}

################################################################################################################
## Create a Cloudfront distribution for the static website
################################################################################################################
Expand Down
5 changes: 0 additions & 5 deletions site-main/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ variable "duplicate-content-penalty-secret" {
type = string
}

variable "deployer" {
type = string
default = null
}

variable "acm-certificate-arn" {
type = string
}
Expand Down
24 changes: 0 additions & 24 deletions site-redirect/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,6 @@ resource "aws_s3_bucket_public_access_block" "this" {
restrict_public_buckets = true
}

################################################################################################################
## Configure the credentials and access to the bucket for a deployment user
################################################################################################################
data "template_file" "deployer_role_policy_file" {
template = file("${path.module}/deployer_role_policy.json")

vars = {
bucket = "site.${replace(replace(var.domain, ".", "-"), "*", "star")}"
}
}

resource "aws_iam_policy" "site_deployer_policy" {
name = "site.${replace(replace(var.domain, ".", "-"), "*", "star")}.deployer"
path = "/"
description = "Policy allowing to publish a new version of the website to the S3 bucket"
policy = data.template_file.deployer_role_policy_file.rendered
}

resource "aws_iam_policy_attachment" "staging-site-deployer-attach-user-policy" {
name = "site.${replace(replace(var.domain, ".", "-"), "*", "star")}-deployer-policy-attachment"
users = [var.deployer]
policy_arn = aws_iam_policy.site_deployer_policy.arn
}

################################################################################################################
## Create a Cloudfront distribution for the static website
################################################################################################################
Expand Down
4 changes: 0 additions & 4 deletions site-redirect/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ variable "duplicate-content-penalty-secret" {
type = string
}

variable "deployer" {
type = string
}

variable "acm-certificate-arn" {
type = string
}
Expand Down

0 comments on commit c77b03e

Please sign in to comment.