Skip to content

Commit

Permalink
Add table aws_iot_thing_group Closes #1994 (#1998)
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthaI authored Apr 29, 2024
1 parent 0dfa4d1 commit 8086570
Show file tree
Hide file tree
Showing 12 changed files with 568 additions and 2 deletions.
6 changes: 6 additions & 0 deletions aws-test/tests/aws_iot_thing_group/test-get-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"arn": "{{ output.resource_aka.value }}",
"group_name": "{{ resourceName }}"
}
]
3 changes: 3 additions & 0 deletions aws-test/tests/aws_iot_thing_group/test-get-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select group_name, arn
from aws.aws_iot_thing_group
where group_name = '{{ resourceName }}';
8 changes: 8 additions & 0 deletions aws-test/tests/aws_iot_thing_group/test-list-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"arn": "{{ output.resource_aka.value }}",
"group_name": "{{ resourceName }}",
"parent_group_name": "parent{{ resourceName }}",
"version": "{{ output.version.value }}"
}
]
3 changes: 3 additions & 0 deletions aws-test/tests/aws_iot_thing_group/test-list-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select group_name, arn, version::text, parent_group_name
from aws.aws_iot_thing_group
where parent_group_name = '{{ output.parent_resource_name.value }}';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
null
3 changes: 3 additions & 0 deletions aws-test/tests/aws_iot_thing_group/test-notfound-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select *
from aws.aws_iot_thing_group
where group_name = 'dummy-{{ resourceName }}';
8 changes: 8 additions & 0 deletions aws-test/tests/aws_iot_thing_group/test-turbot-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"akas": [
"{{ output.resource_aka.value }}"
],
"title": "{{ resourceName }}"
}
]
3 changes: 3 additions & 0 deletions aws-test/tests/aws_iot_thing_group/test-turbot-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select akas, title
from aws.aws_iot_thing_group
where group_name = '{{ resourceName }}';
99 changes: 99 additions & 0 deletions aws-test/tests/aws_iot_thing_group/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
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_iot_thing_group" "parent" {
name = "parent${var.resource_name}"
}

resource "aws_iot_thing_group" "example" {
name = var.resource_name

parent_group_name = aws_iot_thing_group.parent.name

properties {
attribute_payload {
attributes = {
One = "11111"
Two = "TwoTwo"
}
}
description = "This is my thing group"
}

tags = {
terraform = "true"
}
}

output "resource_aka" {
value = aws_iot_thing_group.example.arn
}

output "resource_name" {
value = var.resource_name
}

output "parent_resource_name" {
value = "parent${var.resource_name}"
}

output "version" {
value = aws_iot_thing_group.example.version
}

output "account_id" {
value = data.aws_caller_identity.current.account_id
}

output "aws_partition" {
value = data.aws_partition.current.partition
}

output "aws_region" {
value = var.aws_region
}
5 changes: 3 additions & 2 deletions aws/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,10 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"aws_inspector_assessment_template": tableAwsInspectorAssessmentTemplate(ctx),
"aws_inspector_exclusion": tableAwsInspectorExclusion(ctx),
"aws_inspector_finding": tableAwsInspectorFinding(ctx),
"aws_iot_fleet_metric": tableAwsIoTFleetMetric(ctx),
"aws_iot_fleet_metric": tableAwsIoTFleetMetric(ctx),
"aws_iot_thing": tableAwsIoTThing(ctx),
"aws_iot_thing_type": tableAwsIoTThingType(ctx),
"aws_iot_thing_group": tableAwsIoTThingGroup(ctx),
"aws_iot_thing_type": tableAwsIoTThingType(ctx),
"aws_kinesis_consumer": tableAwsKinesisConsumer(ctx),
"aws_kinesis_firehose_delivery_stream": tableAwsKinesisFirehoseDeliveryStream(ctx),
"aws_kinesis_stream": tableAwsKinesisStream(ctx),
Expand Down
Loading

0 comments on commit 8086570

Please sign in to comment.