Skip to content

[Enhancement]: aws_iam_policy_document compact formatting. #28939

Open
@nairb774

Description

Description

The current implementation of the aws_iam_policy_document generates nicely formatted json as part of its json attribute. For most use cases this isn't a bad thing. We ran into trouble recently when moving a policy from a raw JSON string to an aws_iam_policy_document that is near the limit of what is allowed. When implemented as an aws_iam_policy_document the policy becomes longer than the allowable limit. By applying a json decode/encode to the output like jsonencode(jsondecode(data.aws_iam_policy_document.long_policy.json)) we were able to get back under the limit.

Would it be possible/advisable to remove the indenting being applied or would it be possible to add an additional attribute like compact_json to allow easy access to a more compact representation?

Current pretty formatting is here:

jsonDoc, err := json.MarshalIndent(mergedDoc, "", " ")

Affected Resource(s) and/or Data Source(s)

  • aws_iam_policy_document

Potential Terraform Configuration

No response

References

No response

Would you like to implement a fix?

None

Metadata

Assignees

No one assigned

    Labels

    enhancementRequests to existing resources that expand the functionality or scope.service/iamIssues and PRs that pertain to the iam service.staleOld or inactive issues managed by automation, if no further action taken these will get closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions