File tree 4 files changed +124
-0
lines changed
4 files changed +124
-0
lines changed Original file line number Diff line number Diff line change 1
1
resource "aws_dynamodb_table" "this" {
2
+ // using for_each would be better practice, but would also break compatibility to upstream. Migration move block could be possible
2
3
count = var. create_table && ! var. autoscaling_enabled ? 1 : 0
3
4
4
5
name = var. name
Original file line number Diff line number Diff line change
1
+ provider "aws" {
2
+ profile = " developer-sandbox-administratoraccess"
3
+ }
4
+
5
+ variables {
6
+ tags = {
7
+ // Should be $pwd showing name of the testfile
8
+ " Created_by" : " automated Test autoscaling_apply" ,
9
+ " Created_at" : timestamp ()
10
+ " IaC_Module" : " https://github.com/andsafe-AG/terraform-aws-dynamodb-table"
11
+ // local exec - git branch
12
+ " IaC_Branch" : " main"
13
+ // local exec - git log -1 --pretty=format:%h
14
+ " IaC_Commit" : " hash"
15
+ }
16
+ }
17
+
18
+ run "autoscaling_plan" {
19
+ command = plan
20
+ module {
21
+ source = " ./examples/autoscaling"
22
+ }
23
+ }
24
+
25
+ run "autoscaling_apply" {
26
+ command = apply
27
+
28
+ module {
29
+ source = " ./examples/autoscaling"
30
+ }
31
+ assert {
32
+ condition = module. dynamodb_table . dynamodb_table_id == format (" my-table-%s" , random_pet. this . id )
33
+ error_message = " Name output produced unexpected result"
34
+ }
35
+ assert {
36
+ condition = can (regex (" ^arn:aws:dynamodb:[^:]+:[0-9]{12}:table/[a-zA-Z0-9-]+$" , module. dynamodb_table . dynamodb_table_arn ))
37
+ error_message = format (" ARN %s - output produced unexpected result" , module. dynamodb_table . dynamodb_table_arn )
38
+ }
39
+ }
Original file line number Diff line number Diff line change
1
+ provider "aws" {
2
+ profile = " developer-sandbox-administratoraccess"
3
+ }
4
+
5
+ variables {
6
+ tags = {
7
+ // Should be $pwd showing name of the testfile
8
+ " Created_by" : " automated Test autoscaling_apply" ,
9
+ " Created_at" : timestamp ()
10
+ // local exec - git config --get remote.origin.url
11
+ " IaC_Module" : " https://github.com/andsafe-AG/terraform-aws-dynamodb-table"
12
+ // local exec - git branch
13
+ " IaC_Branch" : " main"
14
+ // local exec - git log -1 --pretty=format:%h
15
+ " IaC_Commit" : " hash"
16
+ }
17
+ }
18
+
19
+
20
+ run "basic_plan" {
21
+ command = plan
22
+ module {
23
+ source = " ./examples/basic"
24
+ }
25
+ }
26
+
27
+ run "basic_apply" {
28
+ command = apply
29
+
30
+ module {
31
+ source = " ./examples/basic"
32
+ }
33
+ assert {
34
+ condition = module. dynamodb_table . dynamodb_table_id == format (" my-table-%s" , random_pet. this . id )
35
+ error_message = " Name output produced unexpected result"
36
+ }
37
+ assert {
38
+ condition = can (regex (" ^arn:aws:dynamodb:[^:]+:[0-9]{12}:table/[a-zA-Z0-9-]+$" , module. dynamodb_table . dynamodb_table_arn ))
39
+ error_message = format (" ARN %s - output produced unexpected result" , module. dynamodb_table . dynamodb_table_arn )
40
+ }
41
+ }
Original file line number Diff line number Diff line change
1
+ provider "aws" {
2
+ profile = " developer-sandbox-administratoraccess"
3
+ }
4
+
5
+ variables {
6
+ tags = {
7
+ // Should be $pwd showing name of the testfile
8
+ " Created_by" : " automated Test autoscaling_apply" ,
9
+ " Created_at" : timestamp ()
10
+ " IaC_Module" : " https://github.com/andsafe-AG/terraform-aws-dynamodb-table"
11
+ // local exec - git branch
12
+ " IaC_Branch" : " main"
13
+ // local exec - git log -1 --pretty=format:%h
14
+ " IaC_Commit" : " hash"
15
+ }
16
+ }
17
+
18
+ run "global_tables_plan" {
19
+ command = plan
20
+ module {
21
+ source = " ./examples/global-tables"
22
+ }
23
+ }
24
+
25
+ run "global_tables_apply" {
26
+ command = apply
27
+
28
+ module {
29
+ source = " ./examples/global-tables"
30
+ }
31
+ assert {
32
+ condition = module. dynamodb_table . dynamodb_table_id == format (" my-table-%s" , random_pet. this . id )
33
+ error_message = " Name output produced unexpected result"
34
+ }
35
+ assert {
36
+ condition = can (regex (" ^arn:aws:dynamodb:[^:]+:[0-9]{12}:table/[a-zA-Z0-9-]+$" , module. dynamodb_table . dynamodb_table_arn ))
37
+ error_message = format (" ARN %s - output produced unexpected result" , module. dynamodb_table . dynamodb_table_arn )
38
+ }
39
+ assert {
40
+ condition = can (regex (" ^arn:aws:dynamodb:[^:]+:[0-9]{12}:table/[a-zA-Z0-9-]+/stream/.+$" , module. dynamodb_table . dynamodb_table_stream_arn ))
41
+ error_message = format (" ARN %s - output produced unexpected result" , module. dynamodb_table . dynamodb_table_stream_arn )
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments