Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
The setting “KMS Customer Master Keys Should Be Used For EFS Encryption” applies to Amazon EFS, not API Gateway. Below are the remediation steps using the AWS Management Console for EFS. (API Gateway doesn’t store data on EFS directly.)
1. Check your existing EFS encryption
- Sign in to the AWS Management Console.
- Go to Amazon EFS.
- In File systems, look at your existing file systems:
- Column Encrypted shows if it’s encrypted.
- Click a file system → General tab → check KMS key.
If it says “aws/elasticfilesystem” or “Not encrypted”, you need to move to a file system using a customer-managed KMS key.
Note: You cannot turn encryption on or change the KMS key for an existing EFS file system. You must create a new encrypted file system and migrate data.
2. Create a customer-managed KMS key (CMK)
- Open the AWS Key Management Service (KMS) console.
- In the left menu, choose Customer managed keys → Create key.
- Key type: Symmetric.
- Key usage: Encrypt and decrypt.
- Key material origin: KMS (default).
- Click Next and configure:
- Alias: e.g.,
alias/efs-prod. - Description: e.g.,
Customer-managed CMK for EFS encryption.
- Alias: e.g.,
- On the Key administrators step, select IAM roles/users who can manage this key.
- On the Key users step, add:
- Any IAM roles/instances/Lambda functions/ECS tasks that will mount and use the EFS.
- Finish the wizard with Create key.
3. Create a new EFS file system encrypted with your CMK
- Go back to the Amazon EFS console.
- Click Create file system.
- Choose the same VPC and Availability Zones as your existing file system.
- Click Customize so you can edit encryption settings.
- Under General settings:
- Encryption: Make sure Enable encryption of data at rest is checked.
- KMS key: From the dropdown, select your customer-managed key (e.g.,
alias/efs-prod).
- Configure Network settings (subnets, security groups) to match your existing EFS as closely as possible.
- Configure Performance and Throughput as needed.
- Click Create.
4. Migrate data from old EFS to new EFS
For each environment (e.g., EC2 instances, container tasks):- On a Linux instance that has network access to both file systems:
- Mount the old EFS:
- Mount the new EFS:
- Mount the old EFS:
- Copy data:
- Verify data and permissions in
/mnt/new-efs.
5. Update applications to use the new EFS
- Update mount targets in:
- EC2
fstabentries. - Auto Scaling/user data scripts.
- ECS task definitions (EFS volume config).
- EKS/containers (PersistentVolume definitions).
- Lambda EFS configuration.
- EC2
- Replace
fs-OLD_IDwithfs-NEW_ID(or the new access point). - Roll out the changes so all clients mount the new encrypted file system.
- Confirm that workloads function normally and write/read from the new EFS.
6. Decommission the old unencrypted / KMS-default EFS
- Once migration is validated and no clients use the old file system:
- In the EFS console, select the old file system.
- Click Delete and confirm.
- Optionally, set a backup / snapshot retention policy for the new EFS (via AWS Backup).
7. (Optional) Prevent future misconfigurations
- Use Service Control Policies (SCPs) or EFS resource policies to:
- Deny creation of EFS file systems without encryption.
- Deny use of the default AWS-managed KMS key for EFS, forcing a customer-managed key.
- In AWS Config or your security tool, enable the rule that checks EFS encryption and KMS key type.
Using CLI
Using CLI
Here’s how to remediate “AWS KMS Customer Master Keys should be used for EFS encryption” using AWS CLI (as you might be doing via API-driven automation such as from an API Gateway–triggered function).AWS EFS cannot change its KMS key after creation. Remediation is:
Note the You can use either
Capture the returned Repeat
- Create a customer-managed KMS key.
- Create a new EFS file system encrypted with that CMK.
- Migrate data from the old EFS to the new one.
- Switch your applications to the new EFS and delete the old one.
1. Create a customer-managed KMS key (CMK)
KeyId from the output.Optional: add a friendly alias:alias/efs-cmk or the KeyId/ARN in later steps.2. Create a new EFS file system encrypted with the CMK
FileSystemId, e.g. fs-1234567890abcdef0.Create one or more mount targets in your VPC subnets:create-mount-target for each AZ/subnet where you need mounts.3. Migrate data from old EFS to new EFS
On an EC2 instance that can reach both file systems:-
Mount the old (unencrypted or AWS-managed-key) EFS:
-
Copy data (example using
rsync): -
Update any application configs (e.g., EC2 user data, fstab, ECS task definitions, EKS PersistentVolumes, etc.) to point to the new EFS
fs-1234567890abcdef0.
4. Remove the old EFS
After verifying everything works on the new file system:-
Unmount on instances:
-
Delete mount targets:
-
Delete the old file system:
5. (Optional) Automating via API Gateway
If your question refers to doing this via API Gateway:- Put these
awsCLI–equivalent operations in a Lambda function (or other service) using AWS SDK. - Expose that Lambda via API Gateway.
- The runtime code will call:
CreateKey,CreateAlias(KMS)CreateFileSystem,CreateMountTarget,DescribeMountTargets,DeleteMountTarget,DeleteFileSystem(EFS)
--encrypted and --kms-key-id referencing a customer-managed CMK.Using Python
Using Python
To meet the control “AWS KMS Customer Master Keys Should Be Used For EFS Encryption” you need:
Optionally create an alias:You can now refer to this key as
This EFS is now encrypted using your CMK and will satisfy the control.
You cannot change encryption or KMS key of an existing EFS file system.
Remediation requires creating a new encrypted EFS and migrating data.You may instead check specifically for the AWS-managed key Then handle mounts + data copy outside of this script.
This does the infrastructure part of remediation; you still must handle the data copy and cutover.
If you clarify whether you want:
- An AWS KMS CMK (customer-managed key)
- EFS file systems encrypted at rest with that CMK
- A migration plan for any existing EFS that are either:
- not encrypted, or
- encrypted with
aws/elasticfilesysteminstead of your CMK
1. Create (or identify) a KMS CMK for EFS
You can either use an existing CMK or create a new one.a) Create a CMK via boto3 (Python)
alias/efs-cmk (recommended) instead of the raw key ID.2. Create new EFS with CMK encryption (compliant going forward)
For any new EFS, you must specify bothEncrypted=True and the KmsKeyId:3. Handle existing non-compliant EFS file systems
Important limitation:You cannot change encryption or KMS key of an existing EFS file system.
Remediation requires creating a new encrypted EFS and migrating data.
a) Detect non‑compliant EFS (not using CMK)
aws/elasticfilesystem by inspecting KmsKeyId, but the above shows the pattern.b) Remediation pattern for each non‑compliant EFS
The high‑level steps (manual or automated):- Create new compliant EFS using the CMK (from step 2).
- Mount both file systems on a temporary EC2 instance (or use AWS DataSync).
- Copy data from old to new EFS (
rsync,cp, DataSync task, etc.). - Update clients (EC2, ECS, EKS, Lambda, etc.) to mount the new EFS.
- Validate application behavior.
- Delete old non‑compliant EFS when safe.
4. Exposing this via API Gateway (optional)
If you want this to be triggered via API Gateway:- Create a Lambda function with the Python code above (or a subset that:
- checks for non‑compliant EFS, and/or
- creates compliant EFS).
- Give Lambda an IAM role with:
kms:CreateKey,kms:DescribeKey,kms:CreateAlias(if creating CMKs),elasticfilesystem:DescribeFileSystems,elasticfilesystem:CreateFileSystem,elasticfilesystem:DescribeTags,elasticfilesystem:CreateTags.
- Create an API Gateway REST API or HTTP API that:
- Integrates a route (e.g.
POST /remediate-efs-kms) with this Lambda.
- Integrates a route (e.g.
- Call that API to perform the remediation.
If you clarify whether you want:
- only detection,
- detection + new EFS creation, or
- a fully automated flow with DataSync and mount updates,
Using Terraform
Using Terraform
THIS_EFSwith your EFS Terraform name.THIS_EFS_CREATION_TOKENwith a unique, stable string for this filesystem (or re-use your existing one if already managed).- Adjust the
aws_kms_keyblock if you already manage a CMK (in that case, reference that key instead of creating a new one).
encrypted from false to true or changing kms_key_id on an existing aws_efs_file_system forces replacement of the EFS file system, which is disruptive and can cause data loss if not migrated first.To verify, terraform plan should show:encryptedset totrue.kms_key_idset to the ARN of the customer-managed KMS key (and no remaining use of the AWS-managed default key).

