Skip to content

Commit d7ac009

Browse files
Codelaxremyleone
andauthored
feat(mnq): add sns (#2274)
* feat(mnq): add sns * add topic and credential resource * state upgrade * ignore topic cassette * begin topic subscription and remove arn from id * refactor mnq ID and ARN helpers * refactor aws attributes helpers merge duplicated helpers between sns and sqs * lint * change sqs and sns urls to https * fix arn and endpoints fields * fix endpoints in queue tests * fix endpoint field name in SNSClient creation * add subscription and change default endpoints * add subscription cassette * lint * tflint and cassette validation for sns 400 * add doc * improve topic test and fix name attribute * update doc * update mnq_sqs_queue endpoint default value in doc * change keys wording * wording for region and project_id attributes doc * Update docs/resources/mnq_sns_topic_subscription.md * nits * add missing descriptions * improve topic_subscription test with topic_arn attribute usage --------- Co-authored-by: Rémy Léone <[email protected]> Co-authored-by: Rémy Léone <[email protected]>
1 parent 9faf1dc commit d7ac009

26 files changed

+6998
-160
lines changed

docs/resources/mnq_sns.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
subcategory: "Messaging and Queuing"
3+
page_title: "Scaleway: scaleway_mnq_sns"
4+
---
5+
6+
# scaleway_mnq_sns
7+
8+
Activate Scaleway Messaging and queuing SNS for a project.
9+
For further information please check
10+
our [documentation](https://www.scaleway.com/en/docs/serverless/messaging/reference-content/sns-overview/)
11+
12+
## Examples
13+
14+
### Basic
15+
16+
Activate SNS for default project
17+
18+
```hcl
19+
resource scaleway_mnq_sns "main" {}
20+
```
21+
22+
Activate SNS for a specific project
23+
24+
```hcl
25+
data scaleway_account_project project {
26+
name = "default"
27+
}
28+
29+
// For specific project in default region
30+
resource scaleway_mnq_sns "for_project" {
31+
project_id = data.scaleway_account_project.project.id
32+
}
33+
```
34+
35+
## Arguments Reference
36+
37+
The following arguments are supported:
38+
39+
40+
- `region` - (Defaults to [provider](../index.md#region) `region`). The [region](../guides/regions_and_zones.md#regions)
41+
in which sns will be enabled.
42+
43+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the sns will be enabled for.
44+
45+
46+
## Attributes Reference
47+
48+
In addition to all arguments above, the following attributes are exported:
49+
50+
- `id` - The ID of the project
51+
52+
~> **Important:** Messaging and Queueing sns' IDs are [regional](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{region}/{id}`, e.g. `fr-par/11111111-1111-1111-1111-111111111111`
53+
54+
- `endpoint` - The endpoint of the SNS service for this project.
55+
56+
## Import
57+
58+
SNS status can be imported using the `{region}/{project_id}`, e.g.
59+
60+
```bash
61+
$ terraform import scaleway_mnq_sns.main fr-par/11111111111111111111111111111111
62+
```
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
subcategory: "Messaging and Queuing"
3+
page_title: "Scaleway: scaleway_mnq_sns_credentials"
4+
---
5+
6+
# scaleway_mnq_sns_credentials
7+
8+
Creates and manages Scaleway Messaging and queuing SNS Credentials.
9+
For further information please check
10+
our [documentation](https://www.scaleway.com/en/docs/serverless/messaging/reference-content/sns-overview/)
11+
12+
## Examples
13+
14+
### Basic
15+
16+
```hcl
17+
resource "scaleway_mnq_sns" "main" {}
18+
19+
resource scaleway_mnq_sns_credentials main {
20+
project_id = scaleway_mnq_sns.main.project_id
21+
name = "sns-credentials"
22+
23+
permissions {
24+
can_manage = false
25+
can_receive = true
26+
can_publish = false
27+
}
28+
}
29+
```
30+
31+
## Arguments Reference
32+
33+
The following arguments are supported:
34+
35+
- `name` - (Optional) The unique name of the sns credentials.
36+
37+
- `permissions` - (Optional). List of permissions associated to these credentials. Only one of permissions may be set.
38+
- `can_publish` - (Optional). Defines if user can publish messages to the service.
39+
- `can_receive` - (Optional). Defines if user can receive messages from the service.
40+
- `can_manage` - (Optional). Defines if user can manage the associated resource(s).
41+
42+
43+
- `region` - (Defaults to [provider](../index.md#region) `region`). The [region](../guides/regions_and_zones.md#regions) in which sns is enabled.
44+
45+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the sns is enabled for.
46+
47+
48+
## Attributes Reference
49+
50+
In addition to all arguments above, the following attributes are exported:
51+
52+
- `id` - The ID of the credentials
53+
54+
~> **Important:** Messaging and Queueing sns credentials' IDs are [regional](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{region}/{id}`, e.g. `fr-par/11111111-1111-1111-1111-111111111111`
55+
56+
- `access_key` - The ID of the key.
57+
- `secret_key` - The secret value of the key.
58+
59+
## Import
60+
61+
SNS credentials can be imported using the `{region}/{id}`, e.g.
62+
63+
```bash
64+
$ terraform import scaleway_mnq_sns_credentials.main fr-par/11111111111111111111111111111111
65+
```

docs/resources/mnq_sns_topic.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
subcategory: "Messaging and Queuing"
3+
page_title: "Scaleway: scaleway_mnq_sns_topic"
4+
---
5+
6+
# scaleway_mnq_sns_topic
7+
8+
Manage Scaleway Messaging and queuing SNS Topics.
9+
For further information please check
10+
our [documentation](https://www.scaleway.com/en/docs/serverless/messaging/reference-content/sns-overview/)
11+
12+
## Examples
13+
14+
### Basic
15+
16+
```hcl
17+
resource "scaleway_mnq_sns" "main" {}
18+
19+
resource scaleway_mnq_sns_credentials main {
20+
project_id = scaleway_mnq_sns.main.project_id
21+
permissions {
22+
can_manage = true
23+
}
24+
}
25+
26+
resource "scaleway_mnq_sns_topic" "topic" {
27+
project_id = scaleway_mnq_sns.main.project_id
28+
name = "my-topic"
29+
access_key = scaleway_mnq_sns_credentials.main.access_key
30+
secret_key = scaleway_mnq_sns_credentials.main.secret_key
31+
}
32+
```
33+
34+
## Arguments Reference
35+
36+
The following arguments are supported:
37+
38+
39+
- `name` - (Optional) The unique name of the sns topic. Either `name` or `name_prefix` is required. Conflicts with `name_prefix`.
40+
41+
- `name_prefix` - (Optional) Creates a unique name beginning with the specified prefix. Conflicts with `name`.
42+
43+
- `access_key` - (Optional) The access key of the SNS credentials.
44+
45+
- `secret_key` - (Optional) The secret key of the SNS credentials.
46+
47+
- `content_based_deduplication` - (Optional) Specifies whether to enable content-based deduplication.
48+
49+
- `fifo_topic` - (Optional) Whether the topic is a FIFO. If true, the topic name must end with .fifo.
50+
51+
- `sns_endpoint` - (Optional) The endpoint of the SNS service. Can contain a {region} placeholder. Defaults to `https://sns.mnq.{region}.scaleway.com`.
52+
53+
- `region` - (Defaults to [provider](../index.md#region) `region`). The [region](../guides/regions_and_zones.md#regions)
54+
in which sns is enabled.
55+
56+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the sns is enabled for.
57+
58+
## Attributes Reference
59+
60+
In addition to all arguments above, the following attributes are exported:
61+
62+
- `id` - The ID of the topic with format `{region}/{project-id}/{topic-name}`
63+
64+
- `arn` - The ARN of the topic
65+
66+
## Import
67+
68+
SNS topic can be imported using the `{region}/{project-id}/{topic-name}`, e.g.
69+
70+
```bash
71+
$ terraform import scaleway_mnq_sns_topic.main fr-par/11111111111111111111111111111111/my-topic
72+
```
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
subcategory: "Messaging and Queuing"
3+
page_title: "Scaleway: scaleway_mnq_sns_topic_subscription"
4+
---
5+
6+
# scaleway_mnq_sns_topic_subscription
7+
8+
Manage Scaleway Messaging and queuing SNS Topic Subscriptions.
9+
For further information please check
10+
our [documentation](https://www.scaleway.com/en/docs/serverless/messaging/reference-content/sns-overview/)
11+
12+
## Examples
13+
14+
### Basic
15+
16+
```hcl
17+
// For default project in default region
18+
resource "scaleway_mnq_sns" "main" {}
19+
20+
resource scaleway_mnq_sns_credentials main {
21+
project_id = scaleway_mnq_sns.main.project_id
22+
permissions {
23+
can_manage = true
24+
can_publish = true
25+
can_receive = true
26+
}
27+
}
28+
29+
resource "scaleway_mnq_sns_topic" "topic" {
30+
project_id = scaleway_mnq_sns.main.project_id
31+
name = "my-topic"
32+
access_key = scaleway_mnq_sns_credentials.main.access_key
33+
secret_key = scaleway_mnq_sns_credentials.main.secret_key
34+
}
35+
36+
resource scaleway_mnq_sns_topic_subscription main {
37+
project_id = scaleway_mnq_sns.main.project_id
38+
access_key = scaleway_mnq_sns_credentials.main.access_key
39+
secret_key = scaleway_mnq_sns_credentials.main.secret_key
40+
topic_id = scaleway_mnq_sns_topic.topic.id
41+
protocol = "http"
42+
endpoint = "http://example.com"
43+
}
44+
```
45+
46+
## Arguments Reference
47+
48+
The following arguments are supported:
49+
50+
51+
- `protocol` - (Required) Protocol of the SNS Topic Subscription.
52+
53+
- `topic_id` - (Optional) The ID of the topic. Either `topic_id` or `topic_arn` is required. Conflicts with `topic_arn`.
54+
55+
- `topic_arn` - (Optional) The ARN of the topic. Either `topic_id` or `topic_arn` is required.
56+
57+
- `access_key` - (Optional) The access key of the SNS credentials.
58+
59+
- `secret_key` - (Optional) The secret key of the SNS credentials.
60+
61+
- `redrive_policy` - (Optional) Activate JSON Redrive Policy.
62+
63+
- `sns_endpoint` - (Optional) The endpoint of the SNS service. Can contain a {region} placeholder. Defaults to `https://sns.mnq.{region}.scaleway.com`.
64+
65+
- `region` - (Defaults to [provider](../index.md#region) `region`). The [region](../guides/regions_and_zones.md#regions)
66+
in which sns is enabled.
67+
68+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the sns is enabled for.
69+
70+
## Attributes Reference
71+
72+
In addition to all arguments above, the following attributes are exported:
73+
74+
- `id` - The ID of the topic with format `{region}/{project-id}/{topic-name}/{subscription-id}`
75+
76+
- `arn` - The ARN of the topic subscription
77+
78+
## Import
79+
80+
SNS topic subscriptions can be imported using the `{region}/{project-id}/{topic-name}/{subscription-id}`, e.g.
81+
82+
```bash
83+
$ terraform import scaleway_mnq_sns_topic_subscription.main fr-par/11111111111111111111111111111111/my-topic/11111111111111111111111111111111
84+
```

docs/resources/mnq_sqs.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,21 @@ our [documentation](https://www.scaleway.com/en/docs/serverless/messaging/refere
1313

1414
### Basic
1515

16+
Activate SQS for default project
17+
1618
```hcl
17-
// For default project in default region
1819
resource "scaleway_mnq_sqs" "main" {}
20+
```
21+
22+
Activate SQS for a specific project
23+
24+
```hcl
25+
data scaleway_account_project project {
26+
name = "default"
27+
}
1928
20-
// For specific project in default region
2129
resource "scaleway_mnq_sqs" "for_project" {
22-
project_id = scaleway_account_project.main.id
30+
project_id = data.scaleway_account_project.project.id
2331
}
2432
```
2533

docs/resources/mnq_sqs_queue.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ resource scaleway_mnq_sqs_credentials main {
2121
name = "sqs-credentials"
2222
2323
permissions {
24-
can_manage = false
25-
can_receive = true
24+
can_manage = true
25+
can_receive = false
2626
can_publish = false
2727
}
2828
}
2929
3030
resource scaleway_mnq_sqs_queue main {
3131
project_id = scaleway_mnq_sqs.main.project_id
3232
name = "my-queue"
33-
endpoint = scaleway_mnq_sqs.main.endpoint
33+
sqs_endpoint = scaleway_mnq_sqs.main.endpoint
3434
access_key = scaleway_mnq_sqs_credentials.main.access_key
3535
secret_key = scaleway_mnq_sqs_credentials.main.secret_key
3636
}
@@ -44,7 +44,7 @@ The following arguments are supported:
4444

4545
- `name_prefix` - (Optional) Creates a unique name beginning with the specified prefix. Conflicts with `name`.
4646

47-
- `endpoint` - (Required) The endpoint of the SQS queue. Can contain a {region} placeholder. Defaults to `http://sqs-sns.mnq.{region}.scw.cloud`.
47+
- `sqs_endpoint` - (Optional) The endpoint of the SQS queue. Can contain a {region} placeholder. Defaults to `https://sqs.mnq.{region}.scaleway.com`.
4848

4949
- `access_key` - (Required) The access key of the SQS queue.
5050

0 commit comments

Comments
 (0)