diff --git a/terraform/aws/ec2.tf b/terraform/aws/ec2.tf index 03134af51e..c5e28ffe96 100644 --- a/terraform/aws/ec2.tf +++ b/terraform/aws/ec2.tf @@ -1,6 +1,6 @@ resource "aws_instance" "web_host" { # ec2 have plain text secrets in user data - # test change + # test change2 ami = var.ami instance_type = "t2.nano" diff --git a/terraform/aws/s3.tf b/terraform/aws/s3.tf index 67bc7c3d77..e33b4352cf 100644 --- a/terraform/aws/s3.tf +++ b/terraform/aws/s3.tf @@ -140,3 +140,27 @@ resource "aws_s3_bucket" "logs" { yor_trace = "01946fe9-aae2-4c99-a975-e9b0d3a4696c" }) } + +resource "aws_s3_bucket_policy" "allow_access_from_another_account" { + bucket = aws_s3_bucket.logs.id + policy = data.aws_iam_policy_document.allow_access_from_another_account.json +} + +data "aws_iam_policy_document" "allow_access_from_another_account" { + statement { + principals { + type = "AWS" + identifiers = ["123456789012"] + } + + actions = [ + "s3:GetObject", + "s3:ListBucket", + ] + + resources = [ + aws_s3_bucket.example.arn, + "${aws_s3_bucket.example.arn}/*", + ] + } +} \ No newline at end of file