Skip to content

Commit

Permalink
update autoscaler version (#87)
Browse files Browse the repository at this point in the history
* update autoscaler version

* readme updated

* Auto Format

Co-authored-by: cloudpossebot <[email protected]>
  • Loading branch information
maximmi and cloudpossebot authored May 20, 2021
1 parent 62a2566 commit 2e7e68f
Show file tree
Hide file tree
Showing 6 changed files with 677 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@

**/.build-harness
**/build-harness

**/.terraform.lock.hcl
58 changes: 56 additions & 2 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,66 @@ provider "aws" {
region = var.region
}

module "dynamodb_table" {
module "dynamodb_table_1" {
source = "../../"

name = "first"
hash_key = "HashKey"
range_key = "RangeKey"
enable_autoscaler = false
enable_autoscaler = true

dynamodb_attributes = [
{
name = "DailyAverage"
type = "N"
},
{
name = "HighWater"
type = "N"
},
{
name = "Timestamp"
type = "S"
}
]

local_secondary_index_map = [
{
name = "TimestampSortIndex"
range_key = "Timestamp"
projection_type = "INCLUDE"
non_key_attributes = ["HashKey", "RangeKey"]
},
{
name = "HighWaterIndex"
range_key = "Timestamp"
projection_type = "INCLUDE"
non_key_attributes = ["HashKey", "RangeKey"]
}
]

global_secondary_index_map = [
{
name = "DailyAverageIndex"
hash_key = "DailyAverage"
range_key = "HighWater"
write_capacity = 5
read_capacity = 5
projection_type = "INCLUDE"
non_key_attributes = ["HashKey", "RangeKey"]
}
]

context = module.this.context
}

module "dynamodb_table_2" {
source = "../../"

name = "second"
hash_key = "HashKey"
range_key = "RangeKey"
enable_autoscaler = true

dynamodb_attributes = [
{
Expand Down
54 changes: 42 additions & 12 deletions examples/complete/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,29 +1,59 @@
output "table_name" {
value = module.dynamodb_table.table_name
output "table_name_1" {
value = module.dynamodb_table_1.table_name
description = "DynamoDB table name"
}

output "table_id" {
value = module.dynamodb_table.table_id
output "table_id_1" {
value = module.dynamodb_table_1.table_id
description = "DynamoDB table ID"
}

output "table_arn" {
value = module.dynamodb_table.table_arn
output "table_arn_1" {
value = module.dynamodb_table_1.table_arn
description = "DynamoDB table ARN"
}

output "global_secondary_index_names" {
value = module.dynamodb_table.global_secondary_index_names
output "global_secondary_index_names_1" {
value = module.dynamodb_table_1.global_secondary_index_names
description = "DynamoDB secondary index names"
}

output "table_stream_arn" {
value = module.dynamodb_table.table_stream_arn
output "table_stream_arn_1" {
value = module.dynamodb_table_1.table_stream_arn
description = "DynamoDB table stream ARN"
}

output "table_stream_label" {
value = module.dynamodb_table.table_stream_label
output "table_stream_label_1" {
value = module.dynamodb_table_1.table_stream_label
description = "DynamoDB table stream label"
}

output "table_name_2" {
value = module.dynamodb_table_2.table_name
description = "DynamoDB table name"
}

output "table_id_2" {
value = module.dynamodb_table_2.table_id
description = "DynamoDB table ID"
}

output "table_arn_2" {
value = module.dynamodb_table_2.table_arn
description = "DynamoDB table ARN"
}

output "global_secondary_index_names_2" {
value = module.dynamodb_table_2.global_secondary_index_names
description = "DynamoDB secondary index names"
}

output "table_stream_arn_2" {
value = module.dynamodb_table_2.table_stream_arn
description = "DynamoDB table stream ARN"
}

output "table_stream_label_2" {
value = module.dynamodb_table_2.table_stream_label
description = "DynamoDB table stream label"
}
22 changes: 18 additions & 4 deletions test/src/examples_complete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,30 @@ func TestExamplesComplete(t *testing.T) {
// At the end of the test, run `terraform destroy` to clean up any resources that were created
defer terraform.Destroy(t, terraformOptions)

// This will run `terraform init` and `terraform plan` and fail the test if there are any errors
terraform.InitAndPlan(t, terraformOptions)

// This will run `terraform init` and `terraform apply` and fail the test if there are any errors
terraform.InitAndApply(t, terraformOptions)

// Run `terraform output` to get the value of an output variable
tableName := terraform.Output(t, terraformOptions, "table_name")
tableName1 := terraform.Output(t, terraformOptions, "table_name_1")
// Verify we're getting back the outputs we expect
assert.Equal(t, "eg-test-first", tableName1)

// Run `terraform output` to get the value of an output variable
tableArn1 := terraform.Output(t, terraformOptions, "table_arn_1")
// Verify we're getting back the outputs we expect
assert.Equal(t, "eg-test-dynamodb-table", tableName)
assert.Contains(t, tableArn1, "table/eg-test-first")

// Run `terraform output` to get the value of an output variable
tableArn := terraform.Output(t, terraformOptions, "table_arn")
tableName2 := terraform.Output(t, terraformOptions, "table_name_2")
// Verify we're getting back the outputs we expect
assert.Contains(t, tableArn, "table/eg-test-dynamodb-table")
assert.Equal(t, "eg-test-second", tableName2)

// Run `terraform output` to get the value of an output variable
tableArn2 := terraform.Output(t, terraformOptions, "table_arn_2")
// Verify we're getting back the outputs we expect
assert.Contains(t, tableArn2, "table/eg-test-second")

}
7 changes: 1 addition & 6 deletions test/src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ go 1.13

require (
github.com/aws/aws-sdk-go v1.34.7 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/gruntwork-io/terratest v0.16.0
github.com/pquerna/otp v1.2.0 // indirect
github.com/gruntwork-io/terratest v0.31.0
github.com/stretchr/testify v1.5.1
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f // indirect
golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e // indirect
)
Loading

0 comments on commit 2e7e68f

Please sign in to comment.