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,22 +27,23 @@ func resourceAwsEfsFileSystem() *schema.Resource {
"creation_token": { "creation_token": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
Computed: true,
ForceNew: true, ForceNew: true,
ValidateFunc: validateMaxLength(64), ValidateFunc: validateMaxLength(64),
}, },
"reference_name": { "reference_name": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, Computed: true,
Deprecated: "Please use attribute `creation_token' instead. This attribute might be removed in future releases.", Deprecated: "Please use attribute `creation_token' instead. This attribute might be removed in future releases.",
ConflictsWith: []string{"creation_token"}, ValidateFunc: validateReferenceName,
ValidateFunc: validateReferenceName,
}, },
"performance_mode": { "performance_mode": {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
Computed: true,
ForceNew: true, ForceNew: true,
ValidateFunc: validatePerformanceModeType, ValidateFunc: validatePerformanceModeType,
}, },
@ -161,6 +162,22 @@ func resourceAwsEfsFileSystemRead(d *schema.ResourceData, meta interface{}) erro
return err 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 return nil
} }

View File

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