provider/aws: Update EFS resource to read performance mode and creation_token

This commit is contained in:
clint shryock 2016-10-05 11:14:12 -05:00 committed by Clint
parent a1d944b70b
commit 5b87cd49a9
2 changed files with 29 additions and 8 deletions

View File

@ -27,6 +27,7 @@ func resourceAwsEfsFileSystem() *schema.Resource {
"creation_token": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validateMaxLength(64),
},
@ -34,15 +35,15 @@ func resourceAwsEfsFileSystem() *schema.Resource {
"reference_name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
Deprecated: "Please use attribute `creation_token' instead. This attribute might be removed in future releases.",
ConflictsWith: []string{"creation_token"},
ValidateFunc: validateReferenceName,
},
"performance_mode": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validatePerformanceModeType,
},
@ -161,6 +162,22 @@ func resourceAwsEfsFileSystemRead(d *schema.ResourceData, meta interface{}) erro
return err
}
var fs *efs.FileSystemDescription
for _, f := range resp.FileSystems {
if d.Id() == *f.FileSystemId {
fs = f
break
}
}
if fs == nil {
log.Printf("[WARN] EFS (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
}
d.Set("creation_token", fs.CreationToken)
d.Set("performance_mode", fs.PerformanceMode)
return nil
}

View File

@ -90,6 +90,10 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
resource.TestStep{
Config: testAccAWSEFSFileSystemConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"aws_efs_file_system.foo",
"performance_mode",
"generalPurpose"),
testAccCheckEfsFileSystem(
"aws_efs_file_system.foo",
),
@ -278,13 +282,13 @@ func testAccCheckEfsFileSystemPerformanceMode(resourceID string, expectedMode st
const testAccAWSEFSFileSystemConfig = `
resource "aws_efs_file_system" "foo" {
reference_name = "radeksimko"
creation_token = "radeksimko"
}
`
const testAccAWSEFSFileSystemConfigWithTags = `
resource "aws_efs_file_system" "foo-with-tags" {
reference_name = "yada_yada"
creation_token = "yada_yada"
tags {
Name = "foo-efs"
Another = "tag"