diff --git a/builtin/providers/aws/resource_aws_efs_file_system.go b/builtin/providers/aws/resource_aws_efs_file_system.go index e3369c8d0..7a4591b03 100644 --- a/builtin/providers/aws/resource_aws_efs_file_system.go +++ b/builtin/providers/aws/resource_aws_efs_file_system.go @@ -27,22 +27,23 @@ func resourceAwsEfsFileSystem() *schema.Resource { "creation_token": { Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, ValidateFunc: validateMaxLength(64), }, "reference_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Deprecated: "Please use attribute `creation_token' instead. This attribute might be removed in future releases.", - ConflictsWith: []string{"creation_token"}, - ValidateFunc: validateReferenceName, + Type: schema.TypeString, + Optional: true, + Computed: true, + Deprecated: "Please use attribute `creation_token' instead. This attribute might be removed in future releases.", + 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 } diff --git a/builtin/providers/aws/resource_aws_efs_file_system_test.go b/builtin/providers/aws/resource_aws_efs_file_system_test.go index 952057f7d..764b98a89 100644 --- a/builtin/providers/aws/resource_aws_efs_file_system_test.go +++ b/builtin/providers/aws/resource_aws_efs_file_system_test.go @@ -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"