-
Notifications
You must be signed in to change notification settings - Fork 12
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
Sohan
authored
Apr 14, 2020
1 parent
dc10769
commit bf4f5ed
Showing
8 changed files
with
253 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
provider "aws" { | ||
region = "eu-west-1" | ||
} | ||
|
||
module "s3_bucket" { | ||
source = "./../../" | ||
|
||
name = "logging-encryption-bucket" | ||
application = "clouddrove" | ||
environment = "test" | ||
label_order = ["environment", "application", "name"] | ||
|
||
region = "eu-west-1" | ||
versioning = true | ||
acl = "private" | ||
bucket_logging_encryption_enabled = true | ||
sse_algorithm = "AES256" | ||
target_bucket = "bucket-logs12" | ||
target_prefix = "logs" | ||
} |
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 @@ | ||
output "id" { | ||
value = module.s3_bucket.*.id | ||
description = "The ID of the s3 bucket." | ||
} | ||
|
||
output "tags" { | ||
value = module.s3_bucket.tags | ||
description = "A mapping of tags to assign to the S3." | ||
} |
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,35 @@ | ||
// Managed By : CloudDrove | ||
// Description : This Terratest is used to test the Terraform S3 module. | ||
// Copyright @ CloudDrove. All Right Reserved. | ||
package test | ||
|
||
import ( | ||
"testing" | ||
"strings" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/gruntwork-io/terratest/modules/terraform" | ||
) | ||
|
||
func Test(t *testing.T) { | ||
t.Parallel() | ||
|
||
terraformOptions := &terraform.Options{ | ||
// Source path of Terraform directory. | ||
TerraformDir: "../../_example/logging-encryption-s3", | ||
Upgrade: true, | ||
} | ||
|
||
// This will run 'terraform init' and 'terraform application' and will fail the test if any errors occur | ||
terraform.InitAndApply(t, terraformOptions) | ||
|
||
// To clean up any resources that have been created, run 'terraform destroy' towards the end of the test | ||
defer terraform.Destroy(t, terraformOptions) | ||
|
||
// To get the value of an output variable, run 'terraform output' | ||
s3BucketId := strings.Join(terraform.OutputList(t, terraformOptions, "id")," ") | ||
Tags := terraform.OutputMap(t, terraformOptions, "tags") | ||
|
||
// Verify we're getting back the outputs we expect | ||
assert.Equal(t, "test-clouddrove-logging-encryption-bucket", s3BucketId) | ||
assert.Equal(t, "test-clouddrove-logging-encryption-bucket", Tags["Name"]) | ||
} |
Oops, something went wrong.