-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
skip: Merge pull request #29 from epam/feature/ecc-aws-043-s3_bucket_…
…lifecycle upd: updated policy 043
- Loading branch information
Showing
5 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
terraform/ecc-aws-043-s3_bucket_lifecycle/red2/provider.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 4" | ||
} | ||
} | ||
} | ||
|
||
provider "aws"{ | ||
profile = var.profile | ||
region = var.default-region | ||
|
||
default_tags { | ||
tags = { | ||
CustodianRule = "ecc-aws-043-s3_bucket_lifecycle" | ||
ComplianceStatus = "Red2" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
resource "aws_s3_bucket" "this" { | ||
bucket = "043-bucket-${random_integer.this.result}-red2" | ||
force_destroy = "true" | ||
} | ||
|
||
resource "random_integer" "this" { | ||
min = 1 | ||
max = 10000000 | ||
} | ||
|
||
resource "aws_s3_bucket_ownership_controls" "this" { | ||
bucket = aws_s3_bucket.this.id | ||
rule { | ||
object_ownership = "BucketOwnerPreferred" | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket_acl" "this" { | ||
depends_on = [aws_s3_bucket_ownership_controls.this] | ||
|
||
bucket = aws_s3_bucket.this.id | ||
acl = "private" | ||
} | ||
|
||
resource "aws_s3_bucket_lifecycle_configuration" "this" { | ||
bucket = aws_s3_bucket.this.bucket | ||
|
||
rule { | ||
id = "log" | ||
|
||
expiration { | ||
days = 90 | ||
} | ||
|
||
filter { | ||
and { | ||
prefix = "log/" | ||
|
||
tags = { | ||
CustodianRule = "ecc-aws-043-s3_bucket_lifecycle" | ||
ComplianceStatus = "Red2" | ||
} | ||
} | ||
} | ||
|
||
status = "Disabled" | ||
|
||
transition { | ||
days = 60 | ||
storage_class = "GLACIER" | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
terraform/ecc-aws-043-s3_bucket_lifecycle/red2/terraform.tfvars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
profile = "c7n" | ||
default-region = "us-east-1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "default-region" { | ||
type = string | ||
description = "Default region for resources will be created" | ||
} | ||
|
||
variable "profile" { | ||
type = string | ||
description = "Profile name configured before running apply" | ||
} |