Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for resource-specific tags #5

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# NOTE: CHANGELOG.md is deprecated

After the release of v1.1.0, please see the [GitHub release notes](https://github.com/babbel/terraform-aws-sns-to-rollbar/releases)
for the module in order to view the most up-to-date changes.

# CHANGELOG.md

## v1.1.0
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,5 @@ module "sns-to-rollbar" {

environment = "test"
level = "debug"

tags = {
app = "some-service"
env = "test"
}
}
```
4 changes: 2 additions & 2 deletions _test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module "sns-to-rollbar-with-json-key" {
environment = "test"
level = "debug"

tags = {
default_tags = {
app = "some-service"
env = "test"
}
Expand All @@ -34,7 +34,7 @@ module "sns-to-rollbar-without-json-key" {
environment = "test"
level = "debug"

tags = {
default_tags = {
app = "some-service"
env = "test"
}
Expand Down
14 changes: 8 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

resource "aws_sns_topic" "this" {
name = var.name
tags = var.tags
tags = merge(var.default_tags, var.sns_topic_tags)
}

resource "aws_sns_topic_subscription" "sqs-queue" {
Expand All @@ -15,7 +15,7 @@ resource "aws_sns_topic_subscription" "sqs-queue" {

resource "aws_sqs_queue" "this" {
name = var.name
tags = var.tags
tags = merge(var.default_tags, var.sqs_queue_tags)
}

data "aws_iam_policy_document" "sqs-queue-consume" {
Expand Down Expand Up @@ -73,7 +73,7 @@ resource "aws_pipes_pipe" "this" {
}
}

tags = var.tags
tags = merge(var.default_tags, var.pipes_pipe_tags)

depends_on = [
aws_iam_role_policy.pipes-pipe-sqs-queue-consume,
Expand All @@ -84,7 +84,8 @@ resource "aws_pipes_pipe" "this" {
resource "aws_iam_role" "pipes-pipe" {
name = "pipes-${var.name}"
assume_role_policy = data.aws_iam_policy_document.pipes-assume-role.json
tags = var.tags

tags = merge(var.default_tags, var.pipes_pipe_iam_role_tags)
}

data "aws_iam_policy_document" "pipes-assume-role" {
Expand Down Expand Up @@ -284,7 +285,7 @@ resource "aws_sfn_state_machine" "this" {
})
)

tags = var.tags
tags = merge(var.default_tags, var.sfn_state_machine_tags)
}

data "aws_iam_policy_document" "sfn-state-machine-start-execution" {
Expand All @@ -297,7 +298,8 @@ data "aws_iam_policy_document" "sfn-state-machine-start-execution" {
resource "aws_iam_role" "sfn-state-machine" {
name = "step-function-${var.name}"
assume_role_policy = data.aws_iam_policy_document.states.json
tags = var.tags

tags = merge(var.default_tags, var.sfn_state_machine_iam_role_tags)
}

data "aws_iam_policy_document" "states" {
Expand Down
59 changes: 57 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
variable "default_tags" {
type = map(string)
default = {}

description = <<EOS
Map of tags assigned to all AWS resources created by this module.
EOS
}

variable "environment" {
type = string

Expand All @@ -12,6 +21,7 @@ variable "json_key" {

description = <<EOS
If the message is JSON, this is the key to use to extract the message used as Rollbar item title.

If the value is "-", the implementation will not attempt to parse the message as JSON.
EOS
}
Expand All @@ -32,6 +42,24 @@ The name used in all related AWS resources.
EOS
}

variable "pipes_pipe_iam_role_tags" {
type = map(string)
default = {}

description = <<EOS
Map of tags assigned to the IAM role used by the Step Function.
EOS
}

variable "pipes_pipe_tags" {
type = map(string)
default = {}

description = <<EOS
Map of tags assigned to the EventBridge Pipe.
EOS
}

variable "rollbar_project_access_token" {
type = object({
access_token = string
Expand All @@ -42,11 +70,38 @@ The Rollbar project access token used to post items to Rollbar. It must the `pos
EOS
}

variable "tags" {
variable "sfn_state_machine_iam_role_tags" {
type = map(string)
default = {}

description = <<EOS
Map of tags assigned to the IAM role used by the Step Function.
EOS
}

variable "sfn_state_machine_tags" {
type = map(string)
default = {}

description = <<EOS
Map of tags assigned to the Step Function.
EOS
}

variable "sns_topic_tags" {
type = map(string)
default = {}

description = <<EOS
Map of tags assigned to the SNS topic.
EOS
}

variable "sqs_queue_tags" {
type = map(string)
default = {}

description = <<EOS
Tags to apply to all AWS resources.
Map of tags assigned to the SQS queue.
EOS
}