terraforming icon indicating copy to clipboard operation
terraforming copied to clipboard

improve-s3

Open sergeylanzman opened this issue 6 years ago • 13 comments

Add many features for s3.

  • [X] Cors https://github.com/dtan4/terraforming/issues/289
  • [X] Website https://github.com/dtan4/terraforming/issues/255
  • [X] Lifecycle rule https://github.com/dtan4/terraforming/issues/232
  • [X] Tags
  • [X] Versioning
  • [X] Logging
  • [ ] Fix tests

Before

resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-bucket"
  acl = "private"
}

After

resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-bucket"
  acl = "private"
 policy = <<POLICY
{
  "Version": "2012-10-17",
  "Id": "AWSConsole-AccessLogs-Policy-1414336270042",
  "Statement": [
    {
      "Sid": "AWSConsoleStmt-1414336270042",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::44444:root"
      },
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::test/AWSLogs/34345/*"
    }
  ]
}
POLICY
  tags {
    "k8s" = "backup"
  }
  cors_rule {
    allowed_methods = [
      "GET"]
    allowed_origins = [
      "*"]
    allowed_headers = [
      "Authorization"]
    max_age_seconds = 3000
  }
  versioning {
    enabled = true
  }
  logging {
    target_bucket = "test"
    target_prefix = ""
  }
  lifecycle_rule {
    id = "Remove 7 days old backups"
    enabled = true
    prefix = ""
    transition {
      storage_class = "STANDARD_IA"
      days = 30
    }
    expiration {
      days = 31
    }
    noncurrent_version_transition {
      days = 30
      storage_class = "STANDARD_IA"
    }
    noncurrent_version_expiration {
      days = 31
    }
    abort_incomplete_multipart_upload_days = 7
  }
  website {
    index_document = "index.html"
    error_document = "ett.html"
    routing_rules = <<EOF
        [
  {
    "condition": {
      "http_error_code_returned_equals": "403"
    },
    "redirect": {
      "host_name": "mywebsite.com",
      "replace_key_prefix_with": "notfound/"
    }
  }
]
    EOF
  }
}

Know issue tfstate not update for new features, but you can run terraform refresh.

sergeylanzman avatar Feb 08 '18 23:02 sergeylanzman

Coverage Status

Coverage decreased (-0.4%) to 99.639% when pulling b9ebfdef04f4530c57925d8ba77a3a2a3bef9333 on sergeylanzman:improve-s3 into c1d467becef5645e14ff822860f3fc2a9868c066 on dtan4:master.

coveralls avatar Feb 08 '18 23:02 coveralls

Coverage Status

Coverage decreased (-0.4%) to 99.639% when pulling b9ebfdef04f4530c57925d8ba77a3a2a3bef9333 on sergeylanzman:improve-s3 into c1d467becef5645e14ff822860f3fc2a9868c066 on dtan4:master.

coveralls avatar Feb 08 '18 23:02 coveralls

Coverage Status

Coverage decreased (-0.4%) to 99.639% when pulling 5bd2c4d3b8217d72293d9f1bc952d4da0d0ed2d7 on sergeylanzman:improve-s3 into c1d467becef5645e14ff822860f3fc2a9868c066 on dtan4:master.

coveralls avatar Feb 08 '18 23:02 coveralls

Sorry for the late review, but could you update unit tests at first?

Thank you for sending a patch to improve!

dtan4 avatar Sep 02 '18 08:09 dtan4

@sergeylanzman @dtan4 Is this currently being worked on? If not then I can produce the tests and get it merged to master?

alexdotsh avatar Nov 01 '18 14:11 alexdotsh

@alexmirkhaydarov I not working on this. I be happy if you can fix tests

sergeylanzman avatar Nov 02 '18 12:11 sergeylanzman

@alexmirkhaydarov please fix the tests

GETandSELECT avatar Jun 23 '19 05:06 GETandSELECT

@GETandSELECT sure, I will try to add the tests in few weeks time.

alexdotsh avatar Jun 24 '19 20:06 alexdotsh

@GETandSELECT @alexmirkhaydarov I wrote more generic solution for reverse terraform process include full support S3 https://github.com/GoogleCloudPlatform/terraformer

sergeylanzman avatar Jun 24 '19 21:06 sergeylanzman

I have fixed the tests under this PR It includes the original work from sergeylanzman and on top of it I added the tests. I'd be happy to push the changes to this branch @sergeylanzman - If you give me access to your repo?

alexdotsh avatar Jul 07 '19 19:07 alexdotsh

@alexmirkhaydarov Done

sergeylanzman avatar Jul 07 '19 22:07 sergeylanzman

Pushed the changes to this branch now to fix the tests. Can you have a look @dtan4?

alexdotsh avatar Jul 08 '19 19:07 alexdotsh

What's the status on this? Can it be merged?

dimisjim avatar Mar 18 '20 10:03 dimisjim