Skip to content

Commit 48cd501

Browse files
committed
Add support for smtp credentials, email sender, and suppressions
Add support for email sender and email suppressions Add TOC for email and smtp resources Add example for TXT record for email delivery Add support for singular datasources for email suppression and sender Fix handling of time created in inputs for datasource
1 parent c0d1134 commit 48cd501

23 files changed

+2040
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ All notable changes to this project are documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/).
55

6-
## 2.1.14 - 2018-07-xx
6+
## 2.1.14 - 2018-07-12
7+
8+
### Added
9+
- Ability to create and manage email approved senders, suppressions, and smtp credentials
710

811
### Changed
912
- Default timeout changed from 5 minutes to 15 minutes to accommodate more resources that don't time out quicker.

docs/Table of Contents.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ This lists all of the available OCI resources and/or data sources.
4949
* **DNS**
5050
* [Records](https://github.com/oracle/terraform-provider-oci/tree/master/docs/dns/records.md)
5151
* [Zones](https://github.com/oracle/terraform-provider-oci/tree/master/docs/dns/zones.md)
52+
* **Email**
53+
* [Senders](https://github.com/oracle/terraform-provider-oci/tree/master/docs/email/senders.md)
54+
* [Suppressions](https://github.com/oracle/terraform-provider-oci/tree/master/docs/email/suppressions.md)
5255
* **File Storage**
5356
* [Exports](https://github.com/oracle/terraform-provider-oci/blob/master/docs/file_storage/exports.md)
5457
* [Export Sets](https://github.com/oracle/terraform-provider-oci/blob/master/docs/file_storage/export_sets.md)
@@ -69,6 +72,7 @@ This lists all of the available OCI resources and/or data sources.
6972
* [Region Subscriptions](https://github.com/oracle/terraform-provider-oci/tree/master/docs/identity/region_subscriptions.md)
7073
* [Regions](https://github.com/oracle/terraform-provider-oci/tree/master/docs/identity/regions.md)
7174
* ~~[Swift Passwords](https://github.com/oracle/terraform-provider-oci/tree/master/docs/identity/swift_passwords.md)~~ [DEPRECATED]
75+
* [Smtp Credentials](https://github.com/oracle/terraform-provider-oci/tree/master/docs/identity/smtp_credentials.md)
7276
* [Tag Namespaces](https://github.com/oracle/terraform-provider-oci/tree/master/docs/identity/tag_namespaces.md)
7377
* [Tags](https://github.com/oracle/terraform-provider-oci/tree/master/docs/identity/tags.md)
7478
* [Tenancies](https://github.com/oracle/terraform-provider-oci/tree/master/docs/identity/tenancies.md)

docs/email/senders.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# oci_email_sender
2+
3+
## Sender Resource
4+
5+
### Sender Reference
6+
7+
The following attributes are exported:
8+
9+
* `email_address` - The email address of the sender.
10+
* `id` - The unique OCID of the sender.
11+
* `is_spf` - Value of the SPF field. For more information about SPF, please see [SPF Authentication](https://docs.us-phoenix-1.oraclecloud.com/Content/Email/Concepts/emaildeliveryoverview.htm#spf).
12+
* `state` - The current status of the approved sender.
13+
* `time_created` - The date and time the approved sender was added in "YYYY-MM-ddThh:mmZ" format with a Z offset, as defined by RFC 3339.
14+
15+
16+
17+
### Create Operation
18+
Creates a sender for a tenancy in a given compartment.
19+
20+
The following arguments are supported:
21+
22+
* `compartment_id` - (Required) The OCID of the compartment that contains the sender.
23+
* `email_address` - (Required) The email address of the sender.
24+
25+
26+
### Update Operation
27+
28+
29+
The following arguments support updates:
30+
* NO arguments in this resource support updates
31+
32+
** IMPORTANT **
33+
Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values
34+
35+
### Example Usage
36+
37+
```hcl
38+
resource "oci_email_sender" "test_sender" {
39+
#Required
40+
compartment_id = "${var.compartment_id}"
41+
email_address = "${var.sender_email_address}"
42+
}
43+
```
44+
45+
46+
## Sender Singular DataSource
47+
48+
49+
### Get Operation
50+
Gets an approved sender for a given `senderId`.
51+
52+
The following arguments are supported:
53+
54+
* `sender_id` - (Required) The unique OCID of the sender.
55+
56+
57+
### Example Usage
58+
59+
```hcl
60+
data "oci_email_sender" "test_sender" {
61+
#Required
62+
sender_id = "${var.sender_sender_id}"
63+
}
64+
```
65+
# oci_email_senders
66+
67+
## Sender DataSource
68+
69+
Gets a list of senders.
70+
71+
### List Operation
72+
Gets a collection of approved sender email addresses and sender IDs.
73+
74+
The following arguments are supported:
75+
76+
* `compartment_id` - (Required) The OCID for the compartment.
77+
* `email_address` - (Optional) The email address of the approved sender.
78+
* `state` - (Optional) The current state of a sender.
79+
80+
81+
The following attributes are exported:
82+
83+
* `senders` - The list of senders.
84+
85+
### Example Usage
86+
87+
```hcl
88+
data "oci_email_senders" "test_senders" {
89+
#Required
90+
compartment_id = "${var.compartment_id}"
91+
92+
#Optional
93+
email_address = "${var.sender_email_address}"
94+
state = "${var.sender_state}"
95+
}
96+
```

docs/email/suppressions.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# oci_email_suppression
2+
3+
## Suppression Resource
4+
5+
### Suppression Reference
6+
7+
The following attributes are exported:
8+
9+
* `email_address` - The email address of the suppression.
10+
* `id` - The unique OCID of the suppression.
11+
* `reason` - The reason that the email address was suppressed. For more information on the types of bounces, see [Suppresion List](https://docs.us-phoenix-1.oraclecloud.com/Content/Email/Concepts/emaildeliveryoverview.htm#suppressionlist).
12+
* `time_created` - The date and time a recipient's email address was added to the suppression list, in "YYYY-MM-ddThh:mmZ" format with a Z offset, as defined by RFC 3339.
13+
14+
15+
16+
### Create Operation
17+
Adds recipient email addresses to the suppression list for a tenancy.
18+
19+
20+
The following arguments are supported:
21+
22+
* `compartment_id` - (Required) The OCID of the compartment to contain the suppression. Since suppressions are at the customer level, this must be the tenancy OCID.
23+
* `email_address` - (Required) The recipient email address of the suppression.
24+
25+
26+
### Update Operation
27+
28+
29+
The following arguments support updates:
30+
* NO arguments in this resource support updates
31+
32+
** IMPORTANT **
33+
Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values
34+
35+
### Example Usage
36+
37+
```hcl
38+
resource "oci_email_suppression" "test_suppression" {
39+
#Required
40+
compartment_id = "${var.tenancy_ocid}"
41+
email_address = "${var.suppression_email_address}"
42+
}
43+
```
44+
45+
46+
## Suppression Singular DataSource
47+
48+
49+
### Get Operation
50+
Gets the details of a suppressed recipient email address for a given
51+
`suppressionId`. Each suppression is given a unique OCID.
52+
53+
54+
The following arguments are supported:
55+
56+
* `suppression_id` - (Required) The unique OCID of the suppression.
57+
58+
59+
### Example Usage
60+
61+
```hcl
62+
data "oci_email_suppression" "test_suppression" {
63+
#Required
64+
suppression_id = "${var.suppression_suppression_id}"
65+
}
66+
```
67+
# oci_email_suppressions
68+
69+
## Suppression DataSource
70+
71+
Gets a list of suppressions.
72+
73+
### List Operation
74+
Gets a list of suppressed recipient email addresses for a user. The
75+
`compartmentId` for suppressions must be a tenancy OCID. The returned list
76+
is sorted by creation time in descending order.
77+
78+
The following arguments are supported:
79+
80+
* `compartment_id` - (Required) The OCID for the compartment.
81+
* `email_address` - (Optional) The email address of the suppression.
82+
* `time_created_greater_than_or_equal_to` - (Optional) Search for suppressions that were created within a specific date range, using this parameter to specify the earliest creation date for the returned list (inclusive). Specifying this parameter without the corresponding `timeCreatedLessThan` parameter will retrieve suppressions created from the given `timeCreatedGreaterThanOrEqualTo` to the current time, in "YYYY-MM-ddThh:mmZ" format with a Z offset, as defined by RFC 3339. **Example:** 2016-12-19T16:39:57.600Z
83+
* `time_created_less_than` - (Optional) Search for suppressions that were created within a specific date range, using this parameter to specify the latest creation date for the returned list (exclusive). Specifying this parameter without the corresponding `timeCreatedGreaterThanOrEqualTo` parameter will retrieve all suppressions created before the specified end date, in "YYYY-MM-ddThh:mmZ" format with a Z offset, as defined by RFC 3339. **Example:** 2016-12-19T16:39:57.600Z
84+
85+
86+
The following attributes are exported:
87+
88+
* `suppressions` - The list of suppressions.
89+
90+
### Example Usage
91+
92+
```hcl
93+
data "oci_email_suppressions" "test_suppressions" {
94+
#Required
95+
compartment_id = "${var.tenancy_ocid}"
96+
97+
#Optional
98+
email_address = "${var.suppression_email_address}"
99+
time_created_greater_than_or_equal_to = "${var.suppression_time_created_greater_than_or_equal_to}"
100+
time_created_less_than = "${var.suppression_time_created_less_than}"
101+
}
102+
```

docs/examples/email/dns.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Configure a DNS that has the TXT record to setup the SPF for the email
2+
resource "oci_dns_zone" "zone1" {
3+
compartment_id = "${var.tenancy_ocid}"
4+
name = "tf-example-primary.oci-email-dns"
5+
zone_type = "PRIMARY"
6+
}
7+
8+
resource "oci_dns_record" "record-txt" {
9+
zone_name_or_id = "${oci_dns_zone.zone1.name}"
10+
rtype = "TXT"
11+
rdata = "v=spf1 include:spf.oracleemaildelivery.com -all"
12+
domain = "${oci_dns_zone.zone1.name}"
13+
ttl = 86400
14+
}
15+
16+
data "oci_dns_records" "records" {
17+
zone_name_or_id = "${oci_dns_zone.zone1.name}"
18+
19+
# optional
20+
compartment_id = "${var.tenancy_ocid}"
21+
domain = "${oci_dns_zone.zone1.name}"
22+
sort_by = "rtype" # domain|rtype|ttl
23+
sort_order = "DESC" # ASC|DESC
24+
}
25+
26+
output "dns_records" {
27+
value = "${data.oci_dns_records.records.records}"
28+
}

docs/examples/email/env-vars

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
### Authentication details
3+
export TF_VAR_tenancy_ocid="<tenancy OCID>"
4+
export TF_VAR_user_ocid="<user OCID>"
5+
export TF_VAR_fingerprint="<PEM key fingerprint>"
6+
export TF_VAR_private_key_path="<path to the private key that matches the fingerprint above>"
7+
8+
### Region
9+
export TF_VAR_region="<region in which to operate, example: us-ashburn-1, us-phoenix-1>"
10+
11+
### Compartment
12+
export TF_VAR_compartment_ocid="<compartment OCID>"
13+
14+
### Public/private keys used on the instance
15+
export TF_VAR_ssh_public_key=$(cat <path to public key>)
16+
export TF_VAR_ssh_private_key=$(cat <path to private key>)
17+
## NOTE: These are not your api keys. More info on the right keys see
18+
## https://docs.us-phoenix-1.oraclecloud.com/Content/Compute/Tasks/managingkeypairs.htm

docs/examples/email/provider.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* This example file shows how to configure the oci provider to target the a single region.
3+
*/
4+
5+
// These variables would commonly be defined as environment variables or sourced in a .env file
6+
variable "tenancy_ocid" {}
7+
variable "user_ocid" {}
8+
variable "fingerprint" {}
9+
variable "private_key_path" {}
10+
variable "compartment_ocid" {}
11+
variable "region" { default = "us-ashburn-1" }
12+
13+
14+
provider "oci" {
15+
region = "${var.region}"
16+
tenancy_ocid = "${var.tenancy_ocid}"
17+
user_ocid = "${var.user_ocid}"
18+
fingerprint = "${var.fingerprint}"
19+
private_key_path = "${var.private_key_path}"
20+
}

docs/examples/email/senders.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
variable "sender_email_address" { default = "[email protected]" }
2+
variable "sender_state" { default = "ACTIVE" }
3+
4+
5+
resource "oci_email_sender" "test_sender" {
6+
#Required
7+
compartment_id = "${var.compartment_ocid}"
8+
email_address = "${var.sender_email_address}"
9+
timeouts {
10+
create = "10m"
11+
}
12+
}
13+
14+
data "oci_email_senders" "test_senders" {
15+
#Required
16+
compartment_id = "${var.compartment_ocid}"
17+
18+
#Optional
19+
email_address = "${var.sender_email_address}"
20+
state = "${var.sender_state}"
21+
22+
filter {
23+
name = "id"
24+
values = ["${oci_email_sender.test_sender.id}"]
25+
}
26+
}
27+
28+
output "emailSenders" {
29+
value = "${data.oci_email_senders.test_senders.senders}"
30+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
variable "suppression_email_address" { default = "[email protected]" }
2+
variable "suppression_time_created_greater_than_or_equal_to" { default = "2018-01-01T00:00:00.000Z" }
3+
variable "suppression_time_created_less_than" { default = "2038-01-01T00:00:00.000Z" }
4+
5+
resource "oci_email_suppression" "test_suppression" {
6+
#Required
7+
compartment_id = "${var.tenancy_ocid}"
8+
email_address = "${var.suppression_email_address}"
9+
}
10+
11+
data "oci_email_suppressions" "test_suppressions" {
12+
#Required
13+
compartment_id = "${var.tenancy_ocid}"
14+
15+
#Optional
16+
email_address = "${var.suppression_email_address}"
17+
time_created_greater_than_or_equal_to = "${var.suppression_time_created_greater_than_or_equal_to}"
18+
time_created_less_than = "${var.suppression_time_created_less_than}"
19+
20+
filter {
21+
name = "id"
22+
values = ["${oci_email_suppression.test_suppression.id}"]
23+
}
24+
}
25+
26+
output "emailSuppressions" {
27+
value = "${data.oci_email_suppressions.test_suppressions.suppressions}"
28+
}

docs/examples/identity/user.tf

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ resource "oci_identity_customer_secret_key" "customer-secret-key1" {
6767
}
6868

6969
data "oci_identity_customer_secret_keys" "customer-secret-keys1" {
70-
user_id = "${oci_identity_user.user1.id}"
70+
user_id = "${oci_identity_customer_secret_key.customer-secret-key1.user_id}"
7171
}
7272

7373
output "customer-secret-key" {
@@ -76,3 +76,19 @@ output "customer-secret-key" {
7676
"${data.oci_identity_customer_secret_keys.customer-secret-keys1.customer_secret_keys}"
7777
]
7878
}
79+
80+
resource "oci_identity_smtp_credential" "smtp-credential-1" {
81+
description = "tf-example-smtp-credential"
82+
user_id = "${oci_identity_user.user1.id}"
83+
}
84+
85+
data "oci_identity_smtp_credentials" "smtp-credentials-1" {
86+
user_id = "${oci_identity_smtp_credential.smtp-credential-1.user_id}"
87+
}
88+
89+
output "smtp-credential" {
90+
value = [
91+
"${oci_identity_smtp_credential.smtp-credential-1.password}",
92+
"${data.oci_identity_smtp_credentials.smtp-credentials-1.smtp_credentials}",
93+
]
94+
}

0 commit comments

Comments
 (0)