providers/aws: sns_topic id-only
This commit is contained in:
parent
edd14e42b3
commit
3a43ce8f8e
|
@ -18,6 +18,7 @@ import (
|
||||||
|
|
||||||
// Mutable attributes
|
// Mutable attributes
|
||||||
var SNSAttributeMap = map[string]string{
|
var SNSAttributeMap = map[string]string{
|
||||||
|
"arn": "TopicArn",
|
||||||
"display_name": "DisplayName",
|
"display_name": "DisplayName",
|
||||||
"policy": "Policy",
|
"policy": "Policy",
|
||||||
"delivery_policy": "DeliveryPolicy",
|
"delivery_policy": "DeliveryPolicy",
|
||||||
|
@ -163,7 +164,6 @@ func resourceAwsSnsTopicRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
attributeOutput, err := snsconn.GetTopicAttributes(&sns.GetTopicAttributesInput{
|
attributeOutput, err := snsconn.GetTopicAttributes(&sns.GetTopicAttributesInput{
|
||||||
TopicArn: aws.String(d.Id()),
|
TopicArn: aws.String(d.Id()),
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NotFound" {
|
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NotFound" {
|
||||||
log.Printf("[WARN] SNS Topic (%s) not found, error code (404)", d.Id())
|
log.Printf("[WARN] SNS Topic (%s) not found, error code (404)", d.Id())
|
||||||
|
@ -198,6 +198,17 @@ func resourceAwsSnsTopicRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we have no name set (import) then determine it from the ARN.
|
||||||
|
// This is a bit of a heuristic for now since AWS provides no other
|
||||||
|
// way to get it.
|
||||||
|
if _, ok := d.GetOk("name"); !ok {
|
||||||
|
arn := d.Get("arn").(string)
|
||||||
|
idx := strings.LastIndex(arn, ":")
|
||||||
|
if idx > -1 {
|
||||||
|
d.Set("name", arn[idx+1:])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
func TestAccAWSSNSTopic_basic(t *testing.T) {
|
func TestAccAWSSNSTopic_basic(t *testing.T) {
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
IDRefreshName: "aws_sns_topic.test_topic",
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAWSSNSTopicDestroy,
|
CheckDestroy: testAccCheckAWSSNSTopicDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
|
@ -30,6 +31,7 @@ func TestAccAWSSNSTopic_basic(t *testing.T) {
|
||||||
func TestAccAWSSNSTopic_withIAMRole(t *testing.T) {
|
func TestAccAWSSNSTopic_withIAMRole(t *testing.T) {
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
IDRefreshName: "aws_sns_topic.test_topic",
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAWSSNSTopicDestroy,
|
CheckDestroy: testAccCheckAWSSNSTopicDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
|
|
Loading…
Reference in New Issue