aws-samples / aws-samples/aws-organized

SCP JSON Content formatting causing "SCP maximum policy size" issue.

Open
#12 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
22
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Problem:
SCPs which are already present in AWS account with size around 500KB are failing at "aws-organized migrate" after importing AWS organization.
The issue is with the formatting in file "/aws_organized/extensions/service_control_policies/service_control_policies.py" line number 32, which add "indent=4" in the ".migration_params.content" JSON value in all files present in "environment/r-3sya/_migrations/" this directory.

Error: "_POLICY_CONTENT_UPDATE: FAILED - You have exceeded the maximum policy size."

Solution: Before executing "aws-organized migrate", if I update all present files in "environment/r-3sya/_migrations/" this directory to remove all spaces/newlines from the JSON present in ".migration_params.content" then there will not be any error.

//Sample bash code
for file_name in environment/r-3sya/_migrations/*;
do
echo updating SCP: $file_name
json_content=$(yq -r .migration_params.content $file_name | jq . -c)
yq --arg jc "$json_content" '.migration_params.content=$jc' $file_name -i -y;
done

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.