provider/aws: Allow import of glacier_vault (#7596)
This commit is contained in:
parent
fc4d548761
commit
40e05ecc33
|
@ -0,0 +1,28 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccAWSGlacierVault_importBasic(t *testing.T) {
|
||||
resourceName := "aws_glacier_vault.full"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckGlacierVaultDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccGlacierVault_full,
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
|
@ -19,6 +20,10 @@ func resourceAwsGlacierVault() *schema.Resource {
|
|||
Update: resourceAwsGlacierVaultUpdate,
|
||||
Delete: resourceAwsGlacierVaultDelete,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
@ -130,7 +135,15 @@ func resourceAwsGlacierVaultRead(d *schema.ResourceData, meta interface{}) error
|
|||
return fmt.Errorf("Error reading Glacier Vault: %s", err.Error())
|
||||
}
|
||||
|
||||
d.Set("arn", *out.VaultARN)
|
||||
awsClient := meta.(*AWSClient)
|
||||
d.Set("name", out.VaultName)
|
||||
d.Set("arn", out.VaultARN)
|
||||
|
||||
location, err := buildGlacierVaultLocation(awsClient.accountid, d.Id())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.Set("location", location)
|
||||
|
||||
tags, err := getGlacierVaultTags(glacierconn, d.Id())
|
||||
if err != nil {
|
||||
|
@ -366,6 +379,13 @@ func glacierPointersToStringList(pointers []*string) []interface{} {
|
|||
return list
|
||||
}
|
||||
|
||||
func buildGlacierVaultLocation(accountId, vaultName string) (string, error) {
|
||||
if accountId == "" {
|
||||
return "", errors.New("AWS account ID unavailable - failed to construct Vault location")
|
||||
}
|
||||
return fmt.Sprintf("/" + accountId + "/vaults/" + vaultName), nil
|
||||
}
|
||||
|
||||
func getGlacierVaultNotification(glacierconn *glacier.Glacier, vaultName string) ([]map[string]interface{}, error) {
|
||||
request := &glacier.GetVaultNotificationsInput{
|
||||
VaultName: aws.String(vaultName),
|
||||
|
|
Loading…
Reference in New Issue