Skip to content

Commit 7525fb8

Browse files
authored
Support support-app slack in account module (#107)
1 parent 8855069 commit 7525fb8

File tree

5 files changed

+145
-1
lines changed

5 files changed

+145
-1
lines changed

modules/account/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ This module creates following resources.
1818
|------|---------|
1919
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
2020
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.10 |
21+
| <a name="requirement_awscc"></a> [awscc](#requirement\_awscc) | >= 0.75 |
2122

2223
## Providers
2324

2425
| Name | Version |
2526
|------|---------|
26-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.19.0 |
27+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.47.0 |
28+
| <a name="provider_awscc"></a> [awscc](#provider\_awscc) | 0.75.0 |
2729

2830
## Modules
2931

@@ -37,18 +39,23 @@ No modules.
3739
| [aws_account_alternate_contact.operation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/account_alternate_contact) | resource |
3840
| [aws_account_alternate_contact.security](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/account_alternate_contact) | resource |
3941
| [aws_account_primary_contact.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/account_primary_contact) | resource |
42+
| [aws_account_region.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/account_region) | resource |
4043
| [aws_iam_account_alias.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_account_alias) | resource |
4144
| [aws_iam_account_password_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_account_password_policy) | resource |
4245
| [aws_iam_security_token_service_preferences.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_security_token_service_preferences) | resource |
4346
| [aws_s3_account_public_access_block.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_account_public_access_block) | resource |
4447
| [aws_spot_datafeed_subscription.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/spot_datafeed_subscription) | resource |
48+
| [awscc_supportapp_account_alias.this](https://registry.terraform.io/providers/hashicorp/awscc/latest/docs/resources/supportapp_account_alias) | resource |
49+
| [awscc_supportapp_slack_channel_configuration.this](https://registry.terraform.io/providers/hashicorp/awscc/latest/docs/resources/supportapp_slack_channel_configuration) | resource |
50+
| [awscc_supportapp_slack_workspace_configuration.this](https://registry.terraform.io/providers/hashicorp/awscc/latest/docs/resources/supportapp_slack_workspace_configuration) | resource |
4551
| [aws_caller_identity.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
4652

4753
## Inputs
4854

4955
| Name | Description | Type | Default | Required |
5056
|------|-------------|------|---------|:--------:|
5157
| <a name="input_name"></a> [name](#input\_name) | (Required) The name for the AWS account. Used for the account alias. | `string` | n/a | yes |
58+
| <a name="input_additional_regions"></a> [additional\_regions](#input\_additional\_regions) | (Optional) A set of regions to enable in the account. | `set(string)` | `[]` | no |
5259
| <a name="input_billing_contact"></a> [billing\_contact](#input\_billing\_contact) | (Optional) The configuration of the billing contact for the AWS Account. `billing_contact` as defined below.<br> (Required) `name` - The name of the billing contact.<br> (Optional) `title` - The tile of the billing contact. Defaults to `Billing Manager`.<br> (Required) `email` - The email address of the billing contact.<br> (Required) `phone` - The phone number of the billing contact. | <pre>object({<br> name = string<br> title = optional(string, "Billing Manager")<br> email = string<br> phone = string<br> })</pre> | `null` | no |
5360
| <a name="input_ec2_spot_datafeed_subscription"></a> [ec2\_spot\_datafeed\_subscription](#input\_ec2\_spot\_datafeed\_subscription) | (Optional) The configuration of the Spot Data Feed Subscription. `ec2_spot_datafeed_subscription` as defined below.<br> (Optional) `enabled` - Indicate whether to enable Spot Data Feed Subscription to S3 Bucket. Defaults to `false`.<br> (Optional) `s3_bucket` - The configuration of the S3 bucket where AWS deliver the spot data feed. `s3_bucket` as defined below.<br> (Required) `name` - The name of the S3 bucket where AWS deliver the spot data feed.<br> (Optional) `key_prefix` - The path of directory inside S3 bucket to place spot pricing data. | <pre>object({<br> enabled = optional(bool, false)<br> s3_bucket = optional(object({<br> name = optional(string, "")<br> key_prefix = optional(string, "")<br> }))<br> })</pre> | `{}` | no |
5461
| <a name="input_operation_contact"></a> [operation\_contact](#input\_operation\_contact) | (Optional) The configuration of the operation contact for the AWS Account. `operation_contact` as defined below.<br> (Required) `name` - The name of the operation contact.<br> (Optional) `title` - The tile of the operation contact. Defaults to `Operation Manager`.<br> (Required) `email` - The email address of the operation contact.<br> (Required) `phone` - The phone number of the operation contact. | <pre>object({<br> name = string<br> title = optional(string, "Operation Manager")<br> email = string<br> phone = string<br> })</pre> | `null` | no |
@@ -57,11 +64,13 @@ No modules.
5764
| <a name="input_s3_public_access_enabled"></a> [s3\_public\_access\_enabled](#input\_s3\_public\_access\_enabled) | (Optional) Whether to enable S3 account-level Public Access Block configuration. Block the public access to S3 bucket if the value is `false`. | `bool` | `false` | no |
5865
| <a name="input_security_contact"></a> [security\_contact](#input\_security\_contact) | (Optional) The configuration of the security contact for the AWS Account. `security_contact` as defined below.<br> (Required) `name` - The name of the security contact.<br> (Optional) `title` - The tile of the security contact. Defaults to `Security Manager`.<br> (Required) `email` - The email address of the security contact.<br> (Required) `phone` - The phone number of the security contact. | <pre>object({<br> name = string<br> title = optional(string, "Security Manager")<br> email = string<br> phone = string<br> })</pre> | `null` | no |
5966
| <a name="input_sts_global_endpoint_token_version"></a> [sts\_global\_endpoint\_token\_version](#input\_sts\_global\_endpoint\_token\_version) | (Optional) The version of the STS global endpoint token. Valid values are `v1` and<br> `v2`. Defaults to `v1`.<br> `v1` - Version 1 Tokens are valid only in AWS Regions that are available by default. These tokens do not work in manually enabled Regions, such as Asia Pacific (Hong Kong).<br> `v2` - Version 2 tokens are valid in all Regions. However, version 2 tokens include more characters and might affect systems where you temporarily store tokens. | `string` | `"v1"` | no |
67+
| <a name="input_support_app"></a> [support\_app](#input\_support\_app) | (Optional) The configuration of the Support App for the AWS Account. `support_app` as defined below.<br> (Optional) `account_alias` - An account alias associated with a customer's account.<br> (Optional) `slack_workspaces` - A set of team ID for each Slack workspace, which uniquely identifies a workspace.<br> (Optional) `slack_channel_configurations` - A list of configurations for each Slack channels. Each block of `slack_channel_configurations` as defined below.<br> (Optional) `name` - The name of the Slack channel configuration.<br> (Required) `workspace` - The team ID of the Slack workspace, which uniquely identifies a workspace.<br> (Required) `channel` - The ID of the Slack channel.<br> (Optional) `permission` - The permission of the default IAM role which created by this module. Valid values are `READ_ONLY` and `FULL_ACCESS`. Defaults to `FULL_ACCESS`.<br> (Optional) `channel_role` - The ARN (Amazon Resource Name) of the IAM role associated with the Support App to post messages to the Slack channel. Only required to override default role which created with `permission`.<br> (Optional) `notification_case_severity` - The severity level of the support case that a customer wants to get notified for. Valid values are `ALL`, `HIGH`, and `NONE`. Defaults to `ALL`.<br> (Optional) `notification_on_add_correspondence_to_case` - Whether to notify when a correspondence is added to a case. Defaults to `true`.<br> (Optional) `notification_on_create_or_reopen_case` - Whether to notify when a case is created or reopened. Defaults to `true`.<br> (Optional) `notification_on_resolve_case` - Whether to notify when a case is resolved. Defaults to `true`. | <pre>object({<br> account_alias = optional(string)<br> slack_workspaces = optional(set(string), [])<br> slack_channel_configurations = optional(list(object({<br> name = optional(string)<br> workspace = string<br> channel = string<br><br> # permission = optional(string, "FULL_ACCESS")<br> channel_role = optional(string)<br><br> notification_case_severity = optional(string, "ALL")<br> notification_on_add_correspondence_to_case = optional(bool, true)<br> notification_on_create_or_reopen_case = optional(bool, true)<br> notification_on_resolve_case = optional(bool, true)<br> })), [])<br> })</pre> | `{}` | no |
6068

6169
## Outputs
6270

6371
| Name | Description |
6472
|------|-------------|
73+
| <a name="output_additional_regions"></a> [additional\_regions](#output\_additional\_regions) | A set of additional regions enabled in the account. |
6574
| <a name="output_billing_contact"></a> [billing\_contact](#output\_billing\_contact) | The billing contact attached to an AWS Account. |
6675
| <a name="output_ec2"></a> [ec2](#output\_ec2) | The account-level configurations of EC2 service.<br> `spot_datafeed_subscription` - To help you understand the charges for your Spot instances, Amazon EC2 provides a data feed that describes your Spot instance usage and pricing. This data feed is sent to an Amazon S3 bucket that you specify when you subscribe to the data feed. |
6776
| <a name="output_id"></a> [id](#output\_id) | The AWS Account ID. |
@@ -73,4 +82,5 @@ No modules.
7382
| <a name="output_security_contact"></a> [security\_contact](#output\_security\_contact) | The security contact attached to an AWS Account. |
7483
| <a name="output_signin_url"></a> [signin\_url](#output\_signin\_url) | The URL to signin for the AWS account. |
7584
| <a name="output_sts"></a> [sts](#output\_sts) | The account-level configurations of STS service.<br> `global_endpoint_token_version` - The version of the STS global endpoint token. |
85+
| <a name="output_support_app"></a> [support\_app](#output\_support\_app) | The account-level configurations of Support App service.<br> `account_alias` - The account alias associated with a customer's account. |
7686
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

modules/account/outputs.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,34 @@ output "sts" {
100100
}
101101
}
102102

103+
output "support_app" {
104+
description = <<EOF
105+
The account-level configurations of Support App service.
106+
`account_alias` - The account alias associated with a customer's account.
107+
EOF
108+
value = {
109+
account_alias = one(awscc_supportapp_account_alias.this[*].account_alias)
110+
slack_workspaces = values(awscc_supportapp_slack_workspace_configuration.this)[*].team_id
111+
slack_channel_configurations = {
112+
for name, configuration in awscc_supportapp_slack_channel_configuration.this :
113+
name => {
114+
name = configuration.channel_name
115+
workspace = configuration.team_id
116+
channel = configuration.channel_id
117+
118+
channel_role = {
119+
arn = configuration.channel_role_arn
120+
}
121+
122+
notification_case_severity = upper(configuration.notify_on_case_severity)
123+
notification_on_add_correspondence_to_case = configuration.notify_on_add_correspondence_to_case
124+
notification_on_create_or_reopen_case = configuration.notify_on_create_or_reopen_case
125+
notification_on_resolve_case = configuration.notify_on_resolve_case
126+
}
127+
}
128+
}
129+
}
130+
103131
output "s3" {
104132
description = <<EOF
105133
The account-level configurations of S3 service.

modules/account/support-app.tf

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
###################################################
2+
# Account Alias for Support App
3+
###################################################
4+
5+
resource "awscc_supportapp_account_alias" "this" {
6+
count = var.support_app.account_alias != null ? 1 : 0
7+
8+
account_alias = var.support_app.account_alias
9+
}
10+
11+
12+
###################################################
13+
# Slack Workspace Authorization for Support App
14+
###################################################
15+
16+
# INFO: Not supported attributes
17+
# - `version_id`
18+
resource "awscc_supportapp_slack_workspace_configuration" "this" {
19+
for_each = var.support_app.slack_workspaces
20+
21+
team_id = each.value
22+
}
23+
24+
25+
###################################################
26+
# Slack Workspace Authorization for Support App
27+
###################################################
28+
29+
resource "awscc_supportapp_slack_channel_configuration" "this" {
30+
for_each = {
31+
for configuration in var.support_app.slack_channel_configurations :
32+
configuration.name => configuration
33+
}
34+
35+
channel_name = each.key
36+
team_id = awscc_supportapp_slack_workspace_configuration.this[each.value.workspace].team_id
37+
channel_id = each.value.channel
38+
39+
40+
## Permissions
41+
# TODO: Use default role with `permission` variable
42+
channel_role_arn = each.value.channel_role
43+
44+
45+
## Notification
46+
notify_on_case_severity = lower(each.value.notification_case_severity)
47+
notify_on_add_correspondence_to_case = each.value.notification_on_add_correspondence_to_case
48+
notify_on_create_or_reopen_case = each.value.notification_on_create_or_reopen_case
49+
notify_on_resolve_case = each.value.notification_on_resolve_case
50+
}

modules/account/variables.tf

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,58 @@ variable "sts_global_endpoint_token_version" {
173173
}
174174
}
175175

176+
variable "support_app" {
177+
description = <<EOF
178+
(Optional) The configuration of the Support App for the AWS Account. `support_app` as defined below.
179+
(Optional) `account_alias` - An account alias associated with a customer's account.
180+
(Optional) `slack_workspaces` - A set of team ID for each Slack workspace, which uniquely identifies a workspace.
181+
(Optional) `slack_channel_configurations` - A list of configurations for each Slack channels. Each block of `slack_channel_configurations` as defined below.
182+
(Optional) `name` - The name of the Slack channel configuration.
183+
(Required) `workspace` - The team ID of the Slack workspace, which uniquely identifies a workspace.
184+
(Required) `channel` - The ID of the Slack channel.
185+
(Optional) `permission` - The permission of the default IAM role which created by this module. Valid values are `READ_ONLY` and `FULL_ACCESS`. Defaults to `FULL_ACCESS`.
186+
(Optional) `channel_role` - The ARN (Amazon Resource Name) of the IAM role associated with the Support App to post messages to the Slack channel. Only required to override default role which created with `permission`.
187+
(Optional) `notification_case_severity` - The severity level of the support case that a customer wants to get notified for. Valid values are `ALL`, `HIGH`, and `NONE`. Defaults to `ALL`.
188+
(Optional) `notification_on_add_correspondence_to_case` - Whether to notify when a correspondence is added to a case. Defaults to `true`.
189+
(Optional) `notification_on_create_or_reopen_case` - Whether to notify when a case is created or reopened. Defaults to `true`.
190+
(Optional) `notification_on_resolve_case` - Whether to notify when a case is resolved. Defaults to `true`.
191+
EOF
192+
type = object({
193+
account_alias = optional(string)
194+
slack_workspaces = optional(set(string), [])
195+
slack_channel_configurations = optional(list(object({
196+
name = optional(string)
197+
workspace = string
198+
channel = string
199+
200+
# permission = optional(string, "FULL_ACCESS")
201+
channel_role = optional(string)
202+
203+
notification_case_severity = optional(string, "ALL")
204+
notification_on_add_correspondence_to_case = optional(bool, true)
205+
notification_on_create_or_reopen_case = optional(bool, true)
206+
notification_on_resolve_case = optional(bool, true)
207+
})), [])
208+
})
209+
default = {}
210+
nullable = false
211+
212+
validation {
213+
condition = alltrue([
214+
for config in var.support_app.slack_channel_configurations :
215+
contains(["ALL", "HIGH", "NONE"], config.notification_case_severity)
216+
])
217+
error_message = "Valid values for `notification_case_severity` are `ALL`, `HIGH`, and `NONE`."
218+
}
219+
# validation {
220+
# condition = alltrue([
221+
# for config in var.support_app.slack_channel_configurations :
222+
# contains(["READ_ONLY", "FULL_ACCESS"], config.permission)
223+
# ])
224+
# error_message = "Valid values for `permission` are `READ_ONLY` and `FULL_ACCESS`."
225+
# }
226+
}
227+
176228
variable "s3_public_access_enabled" {
177229
description = "(Optional) Whether to enable S3 account-level Public Access Block configuration. Block the public access to S3 bucket if the value is `false`."
178230
type = bool

modules/account/versions.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@ terraform {
66
source = "hashicorp/aws"
77
version = ">= 5.10"
88
}
9+
awscc = {
10+
source = "hashicorp/awscc"
11+
version = ">= 0.75"
12+
}
913
}
1014
}

0 commit comments

Comments
 (0)