Skip to content

Commit

Permalink
Add table aws_mq_broker Closes #2005 (#2020)
Browse files Browse the repository at this point in the history
Co-authored-by: Madhushree Ray <[email protected]>
  • Loading branch information
ParthaI and madhushreeray30 authored Jan 8, 2024
1 parent cccfaee commit 6e8c4f3
Show file tree
Hide file tree
Showing 16 changed files with 719 additions and 1 deletion.
7 changes: 7 additions & 0 deletions aws-test/tests/aws_mq_broker/test-get-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"arn": "{{ output.resource_arn.value }}",
"broker_id": "{{ output.resource_id.value }}",
"broker_name": "{{ resourceName }}"
}
]
3 changes: 3 additions & 0 deletions aws-test/tests/aws_mq_broker/test-get-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select arn, broker_name, broker_id
from aws.aws_mq_broker
where broker_id = '{{ output.resource_id.value }}';
8 changes: 8 additions & 0 deletions aws-test/tests/aws_mq_broker/test-list-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"arn": "{{ output.resource_arn.value }}",
"broker_name": "{{ resourceName }}",
"engine_type": "{{ output.engine_type.value }}",
"engine_version": "{{ output.engine_version.value }}"
}
]
3 changes: 3 additions & 0 deletions aws-test/tests/aws_mq_broker/test-list-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select arn, engine_type, engine_version, broker_name
from aws.aws_mq_broker
where broker_name = '{{ resourceName }}';
1 change: 1 addition & 0 deletions aws-test/tests/aws_mq_broker/test-not-found-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
3 changes: 3 additions & 0 deletions aws-test/tests/aws_mq_broker/test-not-found-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select account_id, akas, region, tags, title
from aws.aws_mq_broker
where broker_name = 'dummy';
13 changes: 13 additions & 0 deletions aws-test/tests/aws_mq_broker/test-turbot-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"akas": [
"{{ output.resource_arn.value }}"
],
"broker_name": "{{ resourceName }}",
"region": "{{ output.aws_region.value }}",
"tags": {
"Name": "{{ resourceName }}"
},
"title": "{{ resourceName }}"
}
]
3 changes: 3 additions & 0 deletions aws-test/tests/aws_mq_broker/test-turbot-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select akas, broker_name, region, tags, title
from aws.aws_mq_broker
where broker_name = '{{ resourceName }}';
1 change: 1 addition & 0 deletions aws-test/tests/aws_mq_broker/variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
149 changes: 149 additions & 0 deletions aws-test/tests/aws_mq_broker/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@

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_mq_configuration" "named_test_resource" {
description = "Example Configuration"
name = var.resource_name
engine_type = "ActiveMQ"
engine_version = "5.17.6"

data = <<DATA
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<broker xmlns="http://activemq.apache.org/schema/core">
<plugins>
<forcePersistencyModeBrokerPlugin persistenceFlag="true"/>
<statisticsBrokerPlugin/>
<timeStampingBrokerPlugin ttlCeiling="86400000" zeroExpirationOverride="86400000"/>
</plugins>
</broker>
DATA
}

resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
tags = {
name = var.resource_name
}
}

resource "aws_security_group" "named_test_resource" {
vpc_id = aws_vpc.main.id
name = var.resource_name
description = "Test Security Group."
tags = {
name = var.resource_name
}
}

resource "aws_subnet" "named_test_resource" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
tags = {
Name = var.resource_name
}
}

resource "aws_mq_broker" "named_test_resource" {
depends_on = [aws_subnet.named_test_resource, aws_security_group.named_test_resource, aws_vpc.main, aws_mq_configuration.named_test_resource]
broker_name = var.resource_name

configuration {
id = aws_mq_configuration.named_test_resource.id
revision = aws_mq_configuration.named_test_resource.latest_revision
}

engine_type = "ActiveMQ"
engine_version = "5.17.6"
host_instance_type = "mq.t2.micro"
security_groups = [aws_security_group.named_test_resource.id]
subnet_ids = [aws_subnet.named_test_resource.id]

user {
username = "ExampleUser"
password = "MindTheGapGood"
}

tags = {
Name = var.resource_name
}
}

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

output "aws_region" {
value = data.aws_region.primary.name
}

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

output "resource_arn" {
depends_on = [aws_mq_broker.named_test_resource]
value = aws_mq_broker.named_test_resource.arn
}

output "resource_id" {
depends_on = [aws_mq_broker.named_test_resource]
value = aws_mq_broker.named_test_resource.id
}

output "engine_type" {
value = "ActiveMQ"
}

output "engine_version" {
value = "5.17.6"
}

output "resource_name" {
value = var.resource_name
}
1 change: 1 addition & 0 deletions aws/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"aws_macie2_classification_job": tableAwsMacie2ClassificationJob(ctx),
"aws_media_store_container": tableAwsMediaStoreContainer(ctx),
"aws_mgn_application": tableAwsMGNApplication(ctx),
"aws_mq_broker": tableAwsMQBroker(ctx),
"aws_msk_cluster": tableAwsMSKCluster(ctx),
"aws_msk_serverless_cluster": tableAwsMSKServerlessCluster(ctx),
"aws_neptune_db_cluster": tableAwsNeptuneDBCluster(ctx),
Expand Down
13 changes: 13 additions & 0 deletions aws/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/macie2"
"github.com/aws/aws-sdk-go-v2/service/mediastore"
"github.com/aws/aws-sdk-go-v2/service/mgn"
"github.com/aws/aws-sdk-go-v2/service/mq"
"github.com/aws/aws-sdk-go-v2/service/neptune"
"github.com/aws/aws-sdk-go-v2/service/networkfirewall"
"github.com/aws/aws-sdk-go-v2/service/oam"
Expand Down Expand Up @@ -171,6 +172,7 @@ import (
macie2Endpoint "github.com/aws/aws-sdk-go/service/macie2"
mediastoreEndpoint "github.com/aws/aws-sdk-go/service/mediastore"
mgnEndpoint "github.com/aws/aws-sdk-go/service/mgn"
mqEndpoint "github.com/aws/aws-sdk-go/service/mq"
networkfirewallEndpoint "github.com/aws/aws-sdk-go/service/networkfirewall"
oamEndpoint "github.com/aws/aws-sdk-go/service/oam"
pinpointEndpoint "github.com/aws/aws-sdk-go/service/pinpoint"
Expand Down Expand Up @@ -958,6 +960,17 @@ func MGNClient(ctx context.Context, d *plugin.QueryData) (*mgn.Client, error) {
return mgn.NewFromConfig(*cfg), nil
}

func MQClient(ctx context.Context, d *plugin.QueryData) (*mq.Client, error) {
cfg, err := getClientForQuerySupportedRegion(ctx, d, mqEndpoint.EndpointsID)
if err != nil {
return nil, err
}
if cfg == nil {
return nil, nil
}
return mq.NewFromConfig(*cfg), nil
}

func NeptuneClient(ctx context.Context, d *plugin.QueryData) (*neptune.Client, error) {
cfg, err := getClientForQueryRegion(ctx, d)
if err != nil {
Expand Down
Loading

0 comments on commit 6e8c4f3

Please sign in to comment.