-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add table aws_timestreamwrite_database and aws_timestreamwrite_table C…
- Loading branch information
Showing
26 changed files
with
965 additions
and
3 deletions.
There are no files selected for viewing
Empty file.
6 changes: 6 additions & 0 deletions
6
aws-test/tests/aws_timestreamwrite_database/test-get-expected.json
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,6 @@ | ||
[ | ||
{ | ||
"arn": "{{ output.resource_aka.value }}", | ||
"database_name": "{{ resourceName }}" | ||
} | ||
] |
3 changes: 3 additions & 0 deletions
3
aws-test/tests/aws_timestreamwrite_database/test-get-query.sql
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,3 @@ | ||
select arn, database_name | ||
from aws.aws_timestreamwrite_database | ||
where database_name = '{{ resourceName }}'; |
6 changes: 6 additions & 0 deletions
6
aws-test/tests/aws_timestreamwrite_database/test-list-call-expected.json
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,6 @@ | ||
[ | ||
{ | ||
"arn": "{{ output.resource_aka.value }}", | ||
"database_name": "{{ resourceName }}" | ||
} | ||
] |
3 changes: 3 additions & 0 deletions
3
aws-test/tests/aws_timestreamwrite_database/test-list-call-query.sql
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,3 @@ | ||
select arn, database_name | ||
from aws.aws_timestreamwrite_database | ||
where akas::text = '["{{ output.resource_aka.value }}"]'; |
6 changes: 6 additions & 0 deletions
6
aws-test/tests/aws_timestreamwrite_database/test-turbot-expected.json
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,6 @@ | ||
[ | ||
{ | ||
"akas": ["{{ output.resource_aka.value }}"], | ||
"title": "{{ resourceName }}" | ||
} | ||
] |
3 changes: 3 additions & 0 deletions
3
aws-test/tests/aws_timestreamwrite_database/test-turbot-query.sql
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,3 @@ | ||
select akas, title | ||
from aws.aws_timestreamwrite_database | ||
where akas::text = '["{{ output.resource_aka.value }}"]'; |
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 @@ | ||
{} |
102 changes: 102 additions & 0 deletions
102
aws-test/tests/aws_timestreamwrite_database/variables.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,102 @@ | ||
|
||
variable "resource_name" { | ||
type = string | ||
default = "turbot-test-20200125-create-update" | ||
description = "Name of the resource used throughout the test." | ||
} | ||
|
||
variable "aws_profile" { | ||
type = string | ||
default = "default" | ||
description = "AWS credentials profile used for the test. Default is to use the default profile." | ||
} | ||
|
||
variable "aws_region" { | ||
type = string | ||
default = "us-east-1" | ||
description = "AWS region used for the test. Does not work with default region in config, so must be defined here." | ||
} | ||
|
||
variable "aws_region_alternate" { | ||
type = string | ||
default = "us-east-2" | ||
description = "Alternate AWS region used for tests that require two regions (e.g. DynamoDB global tables)." | ||
} | ||
|
||
provider "aws" { | ||
profile = var.aws_profile | ||
region = var.aws_region | ||
} | ||
|
||
provider "aws" { | ||
alias = "alternate" | ||
profile = var.aws_profile | ||
region = var.aws_region_alternate | ||
} | ||
|
||
data "aws_partition" "current" {} | ||
data "aws_caller_identity" "current" {} | ||
data "aws_region" "primary" {} | ||
data "aws_region" "alternate" { | ||
provider = aws.alternate | ||
} | ||
|
||
data "null_data_source" "resource" { | ||
inputs = { | ||
scope = "arn:${data.aws_partition.current.partition}:::${data.aws_caller_identity.current.account_id}" | ||
} | ||
} | ||
|
||
resource "aws_kms_key" "named_test_resource" { | ||
description = "An example symmetric encryption KMS key" | ||
enable_key_rotation = true | ||
deletion_window_in_days = 20 | ||
} | ||
|
||
resource "aws_kms_key_policy" "named_test_resource" { | ||
key_id = aws_kms_key.named_test_resource.id | ||
policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Id = "key-default-1" | ||
Statement = [ | ||
{ | ||
Sid = "Enable IAM User Permissions" | ||
Effect = "Allow" | ||
Principal = { | ||
AWS = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:root" | ||
}, | ||
Action = "kms:*" | ||
Resource = "*" | ||
} | ||
] | ||
}) | ||
} | ||
|
||
resource "aws_timestreamwrite_database" "named_test_resource" { | ||
database_name = var.resource_name | ||
kms_key_id = aws_kms_key.named_test_resource.arn | ||
|
||
tags = { | ||
Name = var.resource_name | ||
} | ||
} | ||
|
||
output "resource_aka" { | ||
value = aws_timestreamwrite_database.named_test_resource.arn | ||
} | ||
|
||
output "account_id" { | ||
value = data.aws_caller_identity.current.account_id | ||
} | ||
|
||
output "region_name" { | ||
value = data.aws_region.primary.name | ||
} | ||
|
||
output "aws_partition" { | ||
value = data.aws_partition.current.partition | ||
} | ||
|
||
output "resource_name" { | ||
value = var.resource_name | ||
} |
Empty file.
7 changes: 7 additions & 0 deletions
7
aws-test/tests/aws_timestreamwrite_table/test-get-expected.json
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,7 @@ | ||
[ | ||
{ | ||
"arn": "{{ output.resource_aka.value }}", | ||
"database_name": "{{ resourceName }}", | ||
"table_name": "{{ resourceName }}" | ||
} | ||
] |
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,3 @@ | ||
select table_name, arn, database_name | ||
from aws.aws_timestreamwrite_table | ||
where table_name = '{{ resourceName }}' and database_name = '{{ resourceName }}'; |
6 changes: 6 additions & 0 deletions
6
aws-test/tests/aws_timestreamwrite_table/test-list-call-expected.json
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,6 @@ | ||
[ | ||
{ | ||
"arn": "{{ output.resource_aka.value }}", | ||
"table_name": "{{ resourceName }}" | ||
} | ||
] |
3 changes: 3 additions & 0 deletions
3
aws-test/tests/aws_timestreamwrite_table/test-list-call-query.sql
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,3 @@ | ||
select arn, table_name | ||
from aws.aws_timestreamwrite_table | ||
where akas::text = '["{{ output.resource_aka.value }}"]'; |
6 changes: 6 additions & 0 deletions
6
aws-test/tests/aws_timestreamwrite_table/test-turbot-expected.json
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,6 @@ | ||
[ | ||
{ | ||
"akas": ["{{ output.resource_aka.value }}"], | ||
"title": "{{ resourceName }}" | ||
} | ||
] |
3 changes: 3 additions & 0 deletions
3
aws-test/tests/aws_timestreamwrite_table/test-turbot-query.sql
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,3 @@ | ||
select akas, title | ||
from aws.aws_timestreamwrite_table | ||
where akas::text = '["{{ output.resource_aka.value }}"]'; |
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 @@ | ||
{} |
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,116 @@ | ||
|
||
variable "resource_name" { | ||
type = string | ||
default = "turbot-test-20200125-create-update" | ||
description = "Name of the resource used throughout the test." | ||
} | ||
|
||
variable "aws_profile" { | ||
type = string | ||
default = "default" | ||
description = "AWS credentials profile used for the test. Default is to use the default profile." | ||
} | ||
|
||
variable "aws_region" { | ||
type = string | ||
default = "us-east-1" | ||
description = "AWS region used for the test. Does not work with default region in config, so must be defined here." | ||
} | ||
|
||
variable "aws_region_alternate" { | ||
type = string | ||
default = "us-east-2" | ||
description = "Alternate AWS region used for tests that require two regions (e.g. DynamoDB global tables)." | ||
} | ||
|
||
provider "aws" { | ||
profile = var.aws_profile | ||
region = var.aws_region | ||
} | ||
|
||
provider "aws" { | ||
alias = "alternate" | ||
profile = var.aws_profile | ||
region = var.aws_region_alternate | ||
} | ||
|
||
data "aws_partition" "current" {} | ||
data "aws_caller_identity" "current" {} | ||
data "aws_region" "primary" {} | ||
data "aws_region" "alternate" { | ||
provider = aws.alternate | ||
} | ||
|
||
data "null_data_source" "resource" { | ||
inputs = { | ||
scope = "arn:${data.aws_partition.current.partition}:::${data.aws_caller_identity.current.account_id}" | ||
} | ||
} | ||
|
||
resource "aws_kms_key" "named_test_resource" { | ||
description = "An example symmetric encryption KMS key" | ||
enable_key_rotation = true | ||
deletion_window_in_days = 20 | ||
} | ||
|
||
resource "aws_kms_key_policy" "named_test_resource" { | ||
key_id = aws_kms_key.named_test_resource.id | ||
policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Id = "key-default-1" | ||
Statement = [ | ||
{ | ||
Sid = "Enable IAM User Permissions" | ||
Effect = "Allow" | ||
Principal = { | ||
AWS = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:root" | ||
}, | ||
Action = "kms:*" | ||
Resource = "*" | ||
} | ||
] | ||
}) | ||
} | ||
|
||
resource "aws_timestreamwrite_database" "named_test_resource" { | ||
database_name = var.resource_name | ||
kms_key_id = aws_kms_key.named_test_resource.arn | ||
|
||
tags = { | ||
Name = var.resource_name | ||
} | ||
} | ||
|
||
resource "aws_timestreamwrite_table" "named_test_resource" { | ||
database_name = aws_timestreamwrite_database.named_test_resource.database_name | ||
table_name = var.resource_name | ||
|
||
retention_properties { | ||
magnetic_store_retention_period_in_days = 30 | ||
memory_store_retention_period_in_hours = 8 | ||
} | ||
|
||
tags = { | ||
Name = var.resource_name | ||
} | ||
} | ||
|
||
output "resource_aka" { | ||
value = aws_timestreamwrite_table.named_test_resource.arn | ||
} | ||
|
||
output "account_id" { | ||
value = data.aws_caller_identity.current.account_id | ||
} | ||
|
||
output "region_name" { | ||
value = data.aws_region.primary.name | ||
} | ||
|
||
output "aws_partition" { | ||
value = data.aws_partition.current.partition | ||
} | ||
|
||
output "resource_name" { | ||
value = var.resource_name | ||
} |
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
Oops, something went wrong.