generated from cloudposse/terraform-example-module
-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
423 additions
and
160 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
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
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
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
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 |
---|---|---|
@@ -1,10 +1,4 @@ | ||
region = "us-east-2" | ||
|
||
namespace = "eg" | ||
|
||
region = "us-east-2" | ||
namespace = "eg" | ||
environment = "ue2" | ||
|
||
stage = "test" | ||
|
||
name = "example" | ||
|
||
stage = "test" |
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
module "example" { | ||
source = "../.." | ||
provider "aws" { | ||
region = var.region | ||
} | ||
|
||
module "s3_aws_config" { | ||
source = "../../" | ||
|
||
example = var.example | ||
force_destroy = true | ||
|
||
context = module.this.context | ||
} |
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
output "id" { | ||
description = "ID of the created example" | ||
value = module.example.id | ||
output "bucket_domain_name" { | ||
value = module.s3_aws_config.bucket_domain_name | ||
description = "FQDN of bucket" | ||
} | ||
|
||
output "example" { | ||
description = "Output \"example\" from example module" | ||
value = module.example.example | ||
output "bucket_id" { | ||
value = module.s3_aws_config.bucket_id | ||
description = "Bucket Name (aka ID)" | ||
} | ||
|
||
output "random" { | ||
description = "Output \"random\" from example module" | ||
value = module.example.random | ||
output "bucket_arn" { | ||
value = module.s3_aws_config.bucket_arn | ||
description = "Bucket ARN" | ||
} |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
variable "example" { | ||
type = string | ||
description = "The value which will be passed to the example module" | ||
variable "region" { | ||
type = string | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
terraform { | ||
required_version = ">= 0.12.0, < 0.14" | ||
required_version = ">= 0.13.0" | ||
|
||
required_providers { | ||
local = "~> 1.2" | ||
aws = ">=2" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,13 +1,89 @@ | ||
resource "random_integer" "example" { | ||
module "aws_config_label" { | ||
source = "cloudposse/label/null" | ||
version = "0.21.0" | ||
|
||
attributes = ["aws-config"] | ||
context = module.this.context | ||
} | ||
|
||
module "storage" { | ||
source = "cloudposse/s3-log-storage/aws" | ||
version = "0.14.0" | ||
count = module.this.enabled ? 1 : 0 | ||
|
||
lifecycle_prefix = var.lifecycle_prefix | ||
lifecycle_tags = var.lifecycle_tags | ||
force_destroy = var.force_destroy | ||
lifecycle_rule_enabled = var.lifecycle_rule_enabled | ||
versioning_enabled = true | ||
noncurrent_version_expiration_days = var.noncurrent_version_expiration_days | ||
noncurrent_version_transition_days = var.noncurrent_version_transition_days | ||
standard_transition_days = var.standard_transition_days | ||
glacier_transition_days = var.glacier_transition_days | ||
enable_glacier_transition = var.enable_glacier_transition | ||
expiration_days = var.expiration_days | ||
abort_incomplete_multipart_upload_days = var.abort_incomplete_multipart_upload_days | ||
sse_algorithm = var.sse_algorithm | ||
kms_master_key_arn = var.kms_master_key_arn | ||
block_public_acls = true | ||
block_public_policy = true | ||
ignore_public_acls = true | ||
restrict_public_buckets = true | ||
access_log_bucket_name = var.access_log_bucket_name | ||
|
||
tags = module.this.tags | ||
attributes = ["aws-config"] | ||
context = module.this.context | ||
} | ||
|
||
data "aws_iam_policy_document" "aws_config_bucket_policy" { | ||
count = module.this.enabled ? 1 : 0 | ||
|
||
min = 1 | ||
max = 50000 | ||
keepers = { | ||
example = var.example | ||
statement { | ||
principals { | ||
type = "Service" | ||
identifiers = ["config.amazonaws.com"] | ||
} | ||
|
||
effect = "Allow" | ||
|
||
actions = [ | ||
"s3:GetBucketAcl", | ||
"s3:ListBucket", | ||
] | ||
|
||
resources = [ | ||
local.s3_bucket_arn | ||
] | ||
} | ||
|
||
statement { | ||
actions = ["s3:PutObject"] | ||
|
||
effect = "Allow" | ||
|
||
principals { | ||
type = "Service" | ||
identifiers = ["config.amazonaws.com"] | ||
} | ||
|
||
condition { | ||
test = "StringLike" | ||
variable = "s3:x-amz-acl" | ||
values = ["bucket-owner-full-control"] | ||
} | ||
|
||
resources = [local.s3_object_prefix] | ||
} | ||
} | ||
|
||
#----------------------------------------------------------------------------------------------------------------------- | ||
# Locals and Data Sources | ||
#----------------------------------------------------------------------------------------------------------------------- | ||
data "aws_caller_identity" "current" {} | ||
|
||
locals { | ||
example = format("%v %v", var.example, join("", random_integer.example[*].result)) | ||
current_account_id = data.aws_caller_identity.current.account_id | ||
s3_bucket_arn = module.this.enabled ? module.storage[0].bucket_arn : "" | ||
s3_object_prefix = format("%s/AWSLogs/%s/Config/*", local.s3_bucket_arn, local.current_account_id) | ||
} |
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 |
---|---|---|
@@ -1,14 +1,24 @@ | ||
output "id" { | ||
description = "ID of the created example" | ||
value = module.this.enabled ? module.this.id : null | ||
output "bucket_domain_name" { | ||
value = join("", module.storage.*.bucket_domain_name) | ||
description = "FQDN of bucket" | ||
} | ||
|
||
output "example" { | ||
description = "Example output" | ||
value = module.this.enabled ? local.example : null | ||
output "bucket_id" { | ||
value = join("", module.storage.*.bucket_id) | ||
description = "Bucket Name (aka ID)" | ||
} | ||
|
||
output "random" { | ||
description = "Stable random number for this example" | ||
value = module.this.enabled ? join("", random_integer.example[*].result) : null | ||
output "bucket_arn" { | ||
value = join("", module.storage.*.bucket_arn) | ||
description = "Bucket ARN" | ||
} | ||
|
||
output "prefix" { | ||
value = var.lifecycle_prefix | ||
description = "Prefix configured for lifecycle rules" | ||
} | ||
|
||
output "enabled" { | ||
value = module.this.enabled | ||
description = "Is module enabled" | ||
} |
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
Oops, something went wrong.