fix(efs): implement UpdateFileSystemProtection and report protection on describe (#2842)

A file system's replication overwrite protection was missing in two ways that
compound: the operation that sets it did not exist, and the field that reports
it never reached the wire.

UpdateFileSystemProtection had no route, so the terraform AWS provider's PUT to
/2015-02-01/file-systems/{id}/protection fell through to the S3 handler and came
back as an XML error body, which the SDK reported as "deserialization failed,
invalid character '<'". Every consumer of gruntwork's terraform-aws-data-storage
EFS module hits this rather than only those who opt in, because the module emits
the aws_efs_file_system `protection` block unconditionally.

Separately, protection was never reported. createFileSystem left the field null,
and FileSystem's accessor was named getFileSystemProtectionDescription() -- the
*shape* name. Under UpperCamelCaseStrategy the accessor name is the JSON key, so
even a populated field would have gone out as FileSystemProtectionDescription
rather than the member name FileSystemProtection that FileSystemDescription
actually declares.

So:
  - add UpdateFileSystemProtection (PUT .../{FileSystemId}/protection), returning
    FileSystemProtectionDescription, 404 for an unknown file system
  - default new file systems to ENABLED, which is what AWS documents
  - apply that default on read as well, so file systems in a store written before
    protection was modelled describe the same as one created today
  - rename the accessor to getFileSystemProtection()/setFileSystemProtection()

Authority: efs/2015-02-01/service-2.json -- operations.UpdateFileSystemProtection,
shapes.FileSystemDescription.members.FileSystemProtection.

Verified three ways: EfsIntegrationTest 13/13; a real AWS SDK round trip
(create -> describe reports ENABLED -> update DISABLED -> describe reports
DISABLED), which only passes if the wire names match the model; and
terraform-aws-data-storage/examples/efs, previously FLOCI_UNIMPLEMENTED at
apply, now OK through destroy.
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-09-01 10:00:34 -04:00
1 parent 7513b2241b
commit db182b3048
6 files changed
+132 -3

No files matched your search

@@ -46,6 +46,7 @@ class EfsIntegrationTest {
.body("FileSystemId", startsWith("fs-"))
.body("Encrypted", equalTo(true))
.body("NumberOfMountTargets", equalTo(0))
.body("FileSystemProtection.ReplicationOverwriteProtection", equalTo("ENABLED"))
.body("Tags[0].Value", equalTo("MyFS"))
.extract().jsonPath().getString("FileSystemId");
}
@@ -200,6 +201,63 @@ class EfsIntegrationTest {
@Test
@Order(10)
void describeReportsProtectionEnabledByDefault() {
given()
.queryParam("FileSystemId", fileSystemId)
.when()
.get("/2015-02-01/file-systems")
.then()
.statusCode(200)
.body("FileSystems[0].FileSystemProtection.ReplicationOverwriteProtection",
equalTo("ENABLED"));
}
@Test
@Order(11)
void updateFileSystemProtection() {
given()
.contentType("application/json")
.body("""
{
"ReplicationOverwriteProtection": "DISABLED"
}
""")
.when()
.put("/2015-02-01/file-systems/" + fileSystemId + "/protection")
.then()
.statusCode(200)
.body("ReplicationOverwriteProtection", equalTo("DISABLED"));
// The change has to survive the round trip, not just echo back: the terraform
// provider reads protection back through DescribeFileSystems.
given()
.queryParam("FileSystemId", fileSystemId)
.when()
.get("/2015-02-01/file-systems")
.then()
.statusCode(200)
.body("FileSystems[0].FileSystemProtection.ReplicationOverwriteProtection",
equalTo("DISABLED"));
}
@Test
@Order(12)
void updateFileSystemProtectionOnMissingFileSystemIs404() {
given()
.contentType("application/json")
.body("""
{
"ReplicationOverwriteProtection": "DISABLED"
}
""")
.when()
.put("/2015-02-01/file-systems/fs-does-not-exist/protection")
.then()
.statusCode(404);
}
@Test
@Order(13)
void deleteResources() {
given()
.contentType("application/json")