Skip to content

Commit

Permalink
adding bucket policy
Browse files Browse the repository at this point in the history
  • Loading branch information
james-cole2015 committed Oct 4, 2022
1 parent 9ec3399 commit 3a700ec
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ module "aws_data" {
source = "./modules/aws_data"
}

module "iam_module" {
source = "./modules/iam"
identifer = module.aws_data.random_number.result
repo-name = var.repo-name
}


module "s3_storage" {
source = "terraform-aws-modules/s3-bucket/aws"
Expand Down
31 changes: 31 additions & 0 deletions modules/iam/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## s3 backend bucket policy

resource "aws_s3_bucket_policy" "backend-policy" {
bucket = "${var.repo-name}-backend-${var.identifer}"
policy = <<EOT
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": ["arn:aws:iam::835867269469:user/AveryClark","arn:aws:iam::959867141488:user/MatthewDavis"]
},
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::psychic-engine-backend-428127"
},
{
"Effect": "Allow",
"Principal": {
"AWS": ["arn:aws:iam::835867269469:user/AveryClark","arn:aws:iam::959867141488:user/MatthewDavis"]
},
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::psychic-engine-backend-428127/*"
}
]
}
EOT
}
7 changes: 7 additions & 0 deletions modules/iam/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
variable "repo-name" {
type = string
}

variable "identifer" {
type = string
}

0 comments on commit 3a700ec

Please sign in to comment.