From 3112d924b9a97881dad72b0d3a0af4e3f6790a58 Mon Sep 17 00:00:00 2001 From: Itay Zagron Date: Mon, 29 Nov 2021 18:18:38 +0100 Subject: [PATCH 1/4] add KmsMasterKeyId col to sns resource --- .../{7_v0.6.5.down.sql => 7_v0.7.0.down.sql} | 4 ++++ .../migrations/{7_v0.6.5.up.sql => 7_v0.7.0.up.sql} | 4 ++++ resources/sns_topics.go | 10 ++++++++++ 3 files changed, 18 insertions(+) rename resources/migrations/{7_v0.6.5.down.sql => 7_v0.7.0.down.sql} (81%) rename resources/migrations/{7_v0.6.5.up.sql => 7_v0.7.0.up.sql} (80%) diff --git a/resources/migrations/7_v0.6.5.down.sql b/resources/migrations/7_v0.7.0.down.sql similarity index 81% rename from resources/migrations/7_v0.6.5.down.sql rename to resources/migrations/7_v0.7.0.down.sql index 2cdaba76f..2feaca89f 100644 --- a/resources/migrations/7_v0.6.5.down.sql +++ b/resources/migrations/7_v0.7.0.down.sql @@ -1,5 +1,6 @@ ALTER TABLE IF EXISTS "aws_iam_password_policies" DROP COLUMN policy_exists; +<<<<<<< Updated upstream:resources/migrations/7_v0.6.5.down.sql ALTER TABLE IF EXISTS "aws_directconnect_gateways" RENAME COLUMN "state" TO "direct_connect_gateway_state"; ALTER TABLE IF EXISTS "aws_directconnect_gateways" RENAME COLUMN "name" TO "direct_connect_gateway_name"; @@ -15,3 +16,6 @@ ALTER TABLE IF EXISTS "aws_directconnect_gateway_associations" RENAME COLUMN "ga ALTER TABLE IF EXISTS "aws_directconnect_gateway_attachments" DROP COLUMN "gateway_id"; ALTER TABLE IF EXISTS "aws_elbv2_listeners" DROP COLUMN "load_balancer_cq_id"; +======= +ALTER TABLE IF EXISTS "aws_sns_topics" DROP COLUMN kms_master_key_id; +>>>>>>> Stashed changes:resources/migrations/7_v0.7.0.down.sql diff --git a/resources/migrations/7_v0.6.5.up.sql b/resources/migrations/7_v0.7.0.up.sql similarity index 80% rename from resources/migrations/7_v0.6.5.up.sql rename to resources/migrations/7_v0.7.0.up.sql index e5d4e8c70..94bd7ccee 100644 --- a/resources/migrations/7_v0.6.5.up.sql +++ b/resources/migrations/7_v0.7.0.up.sql @@ -1,5 +1,6 @@ ALTER TABLE IF EXISTS "aws_iam_password_policies" ADD COLUMN policy_exists boolean; +<<<<<<< Updated upstream:resources/migrations/7_v0.6.5.up.sql ALTER TABLE IF EXISTS "aws_directconnect_gateways" RENAME COLUMN "direct_connect_gateway_state" TO "state"; @@ -15,3 +16,6 @@ ALTER TABLE IF EXISTS "aws_directconnect_gateway_attachments" ADD COLUMN "gatewa ALTER TABLE IF EXISTS "aws_elbv2_listeners" ADD COLUMN "load_balancer_cq_id" uuid; +======= +ALTER TABLE IF EXISTS "aws_sns_topics" ADD COLUMN kms_master_key_id text; +>>>>>>> Stashed changes:resources/migrations/7_v0.7.0.up.sql diff --git a/resources/sns_topics.go b/resources/sns_topics.go index 7e280f80e..0103ab100 100644 --- a/resources/sns_topics.go +++ b/resources/sns_topics.go @@ -85,6 +85,11 @@ func SnsTopics() *schema.Table { Description: "Enables content-based deduplication for FIFO topics.", Type: schema.TypeBool, }, + { + Name: "kms_master_key_id", + Description: "The ID of an AWS managed customer master key (CMK) for Amazon SNS or a custom CMK", + Type: schema.TypeString, + }, { Name: "arn", Description: "The topic's ARN.", @@ -172,6 +177,11 @@ func resolveTopicAttributes(ctx context.Context, meta schema.ClientMeta, resourc return err } } + if p, ok := output.Attributes["KmsMasterKeyId"]; ok && p != "" { + if err := resource.Set("kms_master_key_id", p); err != nil { + return err + } + } return nil } From cd7b53499ee77f3157bd5c26d2e90d10210aa772 Mon Sep 17 00:00:00 2001 From: Itay Zagron Date: Mon, 29 Nov 2021 18:21:32 +0100 Subject: [PATCH 2/4] remove conflicts --- resources/migrations/7_v0.7.0.down.sql | 4 +--- resources/migrations/7_v0.7.0.up.sql | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/resources/migrations/7_v0.7.0.down.sql b/resources/migrations/7_v0.7.0.down.sql index 2feaca89f..c64a934cd 100644 --- a/resources/migrations/7_v0.7.0.down.sql +++ b/resources/migrations/7_v0.7.0.down.sql @@ -1,6 +1,5 @@ ALTER TABLE IF EXISTS "aws_iam_password_policies" DROP COLUMN policy_exists; -<<<<<<< Updated upstream:resources/migrations/7_v0.6.5.down.sql ALTER TABLE IF EXISTS "aws_directconnect_gateways" RENAME COLUMN "state" TO "direct_connect_gateway_state"; ALTER TABLE IF EXISTS "aws_directconnect_gateways" RENAME COLUMN "name" TO "direct_connect_gateway_name"; @@ -16,6 +15,5 @@ ALTER TABLE IF EXISTS "aws_directconnect_gateway_associations" RENAME COLUMN "ga ALTER TABLE IF EXISTS "aws_directconnect_gateway_attachments" DROP COLUMN "gateway_id"; ALTER TABLE IF EXISTS "aws_elbv2_listeners" DROP COLUMN "load_balancer_cq_id"; -======= + ALTER TABLE IF EXISTS "aws_sns_topics" DROP COLUMN kms_master_key_id; ->>>>>>> Stashed changes:resources/migrations/7_v0.7.0.down.sql diff --git a/resources/migrations/7_v0.7.0.up.sql b/resources/migrations/7_v0.7.0.up.sql index 94bd7ccee..82caaa8a3 100644 --- a/resources/migrations/7_v0.7.0.up.sql +++ b/resources/migrations/7_v0.7.0.up.sql @@ -1,7 +1,5 @@ ALTER TABLE IF EXISTS "aws_iam_password_policies" ADD COLUMN policy_exists boolean; -<<<<<<< Updated upstream:resources/migrations/7_v0.6.5.up.sql - ALTER TABLE IF EXISTS "aws_directconnect_gateways" RENAME COLUMN "direct_connect_gateway_state" TO "state"; ALTER TABLE IF EXISTS "aws_directconnect_gateways" RENAME COLUMN "direct_connect_gateway_name" TO "name"; @@ -14,8 +12,6 @@ ALTER TABLE IF EXISTS "aws_directconnect_gateway_associations" RENAME COLUMN "di ALTER TABLE IF EXISTS "aws_directconnect_gateway_attachments" ADD COLUMN "gateway_id" text; - ALTER TABLE IF EXISTS "aws_elbv2_listeners" ADD COLUMN "load_balancer_cq_id" uuid; -======= + ALTER TABLE IF EXISTS "aws_sns_topics" ADD COLUMN kms_master_key_id text; ->>>>>>> Stashed changes:resources/migrations/7_v0.7.0.up.sql From c098b50a6cf8f99f2986c3079ab5a4bc0e0fe1d5 Mon Sep 17 00:00:00 2001 From: Itay Zagron Date: Mon, 29 Nov 2021 19:19:57 +0100 Subject: [PATCH 3/4] updated docs --- docs/tables/aws_sns_topics.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/tables/aws_sns_topics.md b/docs/tables/aws_sns_topics.md index 1115ddccc..83aeea29b 100644 --- a/docs/tables/aws_sns_topics.md +++ b/docs/tables/aws_sns_topics.md @@ -16,4 +16,5 @@ AWS SNS topic |effective_delivery_policy|jsonb|The JSON serialization of the effective delivery policy, taking system defaults into account.| |fifo_topic|boolean|When this is set to true, a FIFO topic is created.| |content_based_deduplication|boolean|Enables content-based deduplication for FIFO topics.| +|kms_master_key_id|text|The ID of an AWS managed customer master key (CMK) for Amazon SNS or a custom CMK| |arn|text|The topic's ARN.| From d1899a383a2442b0fb7a3541e53030739443a2f9 Mon Sep 17 00:00:00 2001 From: Itay Zagron Date: Mon, 29 Nov 2021 19:28:06 +0100 Subject: [PATCH 4/4] fixed tests --- client/mocks/builders_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/client/mocks/builders_test.go b/client/mocks/builders_test.go index 8db4031d8..f61f04629 100644 --- a/client/mocks/builders_test.go +++ b/client/mocks/builders_test.go @@ -636,6 +636,7 @@ func buildSnsTopics(t *testing.T, ctrl *gomock.Controller) client.Services { "FifoTopic": "false", "ContentBasedDeduplication": "true", "DisplayName": "cloudquery", + "KmsMasterKeyId": "test/key", "Owner": "owner", "Policy": `{"stuff": 3}`, "DeliveryPolicy": `{"stuff": 3}`,