Skip to content

Instantly share code, notes, and snippets.

@refayathaque
Last active March 21, 2021 19:51
Show Gist options
  • Select an option

  • Save refayathaque/b520a9ffa9a8b4d8f0eacdcd85aa5b64 to your computer and use it in GitHub Desktop.

Select an option

Save refayathaque/b520a9ffa9a8b4d8f0eacdcd85aa5b64 to your computer and use it in GitHub Desktop.

Revisions

  1. refayathaque revised this gist Mar 21, 2021. No changes.
  2. refayathaque revised this gist Mar 20, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions s3.tf
    Original file line number Diff line number Diff line change
    @@ -15,8 +15,8 @@ data "aws_iam_policy_document" "bucket_website_hosting" {
    "s3:ListBucket",
    ]
    principals {
    identifiers = [ aws_cloudfront_origin_access_identity.origin_access_identity.iam_arn ]
    type = "AWS"
    identifiers = [aws_cloudfront_origin_access_identity.origin_access_identity.iam_arn]
    type = "AWS"
    }
    resources = [
    "arn:aws:s3:::${var.BUCKET_NAME}",
    @@ -29,5 +29,5 @@ resource "null_resource" "upload_static_files" {
    provisioner "local-exec" {
    command = "aws s3 cp index.html s3://${var.BUCKET_NAME}"
    }
    depends_on = [ aws_s3_bucket.website_static_files ]
    depends_on = [aws_s3_bucket.website_static_files]
    }
  3. refayathaque revised this gist Mar 20, 2021. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions s3.tf
    Original file line number Diff line number Diff line change
    @@ -15,8 +15,7 @@ data "aws_iam_policy_document" "bucket_website_hosting" {
    "s3:ListBucket",
    ]
    principals {
    identifiers = [
    aws_cloudfront_origin_access_identity.origin_access_identity.iam_arn]
    identifiers = [ aws_cloudfront_origin_access_identity.origin_access_identity.iam_arn ]
    type = "AWS"
    }
    resources = [
    @@ -30,5 +29,5 @@ resource "null_resource" "upload_static_files" {
    provisioner "local-exec" {
    command = "aws s3 cp index.html s3://${var.BUCKET_NAME}"
    }
    depends_on = [aws_s3_bucket.website_static_files]
    depends_on = [ aws_s3_bucket.website_static_files ]
    }
  4. refayathaque renamed this gist Mar 20, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. refayathaque revised this gist Mar 20, 2021. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,5 @@ resource "null_resource" "upload_static_files" {
    provisioner "local-exec" {
    command = "aws s3 cp index.html s3://${var.BUCKET_NAME}"
    }

    depends_on = [aws_s3_bucket.website_static_files]
    }
  6. refayathaque created this gist Mar 20, 2021.
    35 changes: 35 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    resource "aws_s3_bucket" "website_static_files" {
    bucket = var.BUCKET_NAME
    acl = "private"
    policy = data.aws_iam_policy_document.bucket_website_hosting.json
    website {
    index_document = "index.html"
    }
    force_destroy = true
    }

    data "aws_iam_policy_document" "bucket_website_hosting" {
    statement {
    actions = [
    "s3:GetObject",
    "s3:ListBucket",
    ]
    principals {
    identifiers = [
    aws_cloudfront_origin_access_identity.origin_access_identity.iam_arn]
    type = "AWS"
    }
    resources = [
    "arn:aws:s3:::${var.BUCKET_NAME}",
    "arn:aws:s3:::${var.BUCKET_NAME}/*",
    ]
    }
    }

    resource "null_resource" "upload_static_files" {
    provisioner "local-exec" {
    command = "aws s3 cp index.html s3://${var.BUCKET_NAME}"
    }

    depends_on = [aws_s3_bucket.website_static_files]
    }