Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
259 views
in Technique[技术] by (71.8m points)

Is there a way to compress a JSON file with Terraform?

When generating JSON document types using Terraform (e.g. for policy documents) it will default to providing nice indentation, like:

{
    "Version":"2021-01-27",
    "ArrayOfThings": [
        "Thing",
        "OtherThing",
    ]
}

However, some document types in AWS have limited sizes. Is there a way of controlling what the output formatting for the documents generated by Terraform is (i.e. not the terraform --json output, a step in the document itself)?

Ideally I'd like to use the Terraform provider (which has a json output) and then connect that through a minifier, so it would end up being published to AWS as:

{"Version":"2021-01-27","ArrayOfThings":["Thing","OtherThing"]}

The Hashicorp terraform rule that I'd explicitly like to use this on is the aws_iam_policy_document one, which has a .json output. Is there an equivalent .jsonCompressed or another Terraform rule that I can use the output of aws_iam_policy_document to minify the JSON output?

question from:https://stackoverflow.com/questions/65921768/is-there-a-way-to-compress-a-json-file-with-terraform

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...