Merge branch 'ses-arn' of https://github.com/joshuaspence/terraform into joshuaspence-ses-arn
This commit is contained in:
commit
880071ded5
|
@ -19,12 +19,16 @@ func resourceAwsSesDomainIdentity() *schema.Resource {
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
|
"arn": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"domain": &schema.Schema{
|
"domain": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"verification_token": &schema.Schema{
|
"verification_token": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
@ -77,6 +81,7 @@ func resourceAwsSesDomainIdentityRead(d *schema.ResourceData, meta interface{})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d.Set("arn", fmt.Sprintf("arn:%s:ses:%s:%s:identity/%s", meta.(*AWSClient).partition, meta.(*AWSClient).region, meta.(*AWSClient).accountid, d.Id()))
|
||||||
d.Set("verification_token", verificationAttrs.VerificationToken)
|
d.Set("verification_token", verificationAttrs.VerificationToken)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAwsSESDomainIdentity_basic(t *testing.T) {
|
func TestAccAwsSESDomainIdentity_basic(t *testing.T) {
|
||||||
|
domain := fmt.Sprintf(
|
||||||
|
"%s.terraformtesting.com",
|
||||||
|
acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() {
|
PreCheck: func() {
|
||||||
testAccPreCheck(t)
|
testAccPreCheck(t)
|
||||||
|
@ -20,12 +24,10 @@ func TestAccAwsSESDomainIdentity_basic(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckAwsSESDomainIdentityDestroy,
|
CheckDestroy: testAccCheckAwsSESDomainIdentityDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: fmt.Sprintf(
|
Config: fmt.Sprintf(testAccAwsSESDomainIdentityConfig, domain),
|
||||||
testAccAwsSESDomainIdentityConfig,
|
|
||||||
acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum),
|
|
||||||
),
|
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAwsSESDomainIdentityExists("aws_ses_domain_identity.test"),
|
testAccCheckAwsSESDomainIdentityExists("aws_ses_domain_identity.test"),
|
||||||
|
testAccCheckAwsSESDomainIdentityArn("aws_ses_domain_identity.test", domain),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -93,8 +95,27 @@ func testAccCheckAwsSESDomainIdentityExists(n string) resource.TestCheckFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testAccCheckAwsSESDomainIdentityArn(n string, domain string) resource.TestCheckFunc {
|
||||||
|
return func(s *terraform.State) error {
|
||||||
|
rs, _ := s.RootModule().Resources[n]
|
||||||
|
|
||||||
|
expected := fmt.Sprintf(
|
||||||
|
"arn:%s:ses:%s:%s:identity/%s",
|
||||||
|
testAccProvider.Meta().(*AWSClient).partition,
|
||||||
|
testAccProvider.Meta().(*AWSClient).region,
|
||||||
|
testAccProvider.Meta().(*AWSClient).accountid,
|
||||||
|
domain)
|
||||||
|
|
||||||
|
if rs.Primary.Attributes["arn"] != expected {
|
||||||
|
return fmt.Errorf("Incorrect ARN: expected %q, got %q", expected, rs.Primary.Attributes["arn"])
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const testAccAwsSESDomainIdentityConfig = `
|
const testAccAwsSESDomainIdentityConfig = `
|
||||||
resource "aws_ses_domain_identity" "test" {
|
resource "aws_ses_domain_identity" "test" {
|
||||||
domain = "%s.terraformtesting.com"
|
domain = "%s"
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
|
@ -15,11 +15,13 @@ Provides an SES domain identity resource
|
||||||
The following arguments are supported:
|
The following arguments are supported:
|
||||||
|
|
||||||
* `domain` - (Required) The domain name to assign to SES
|
* `domain` - (Required) The domain name to assign to SES
|
||||||
|
|
||||||
## Attributes Reference
|
## Attributes Reference
|
||||||
|
|
||||||
The following attributes are exported:
|
The following attributes are exported:
|
||||||
|
|
||||||
|
* `arn` - The ARN of the domain identity.
|
||||||
|
|
||||||
* `verification_token` - A code which when added to the domain as a TXT record
|
* `verification_token` - A code which when added to the domain as a TXT record
|
||||||
will signal to SES that the owner of the domain has authorised SES to act on
|
will signal to SES that the owner of the domain has authorised SES to act on
|
||||||
their behalf. The domain identity will be in state "verification pending"
|
their behalf. The domain identity will be in state "verification pending"
|
||||||
|
@ -41,6 +43,6 @@ resource "aws_route53_record" "example_amazonses_verification_record" {
|
||||||
type = "TXT"
|
type = "TXT"
|
||||||
ttl = "600"
|
ttl = "600"
|
||||||
records = ["${aws_ses_domain_identity.example.verification_token}"]
|
records = ["${aws_ses_domain_identity.example.verification_token}"]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue