aws-cloudformation / cfn-language-discussion

Language discussions for CloudFormation template language
https://aws.amazon.com/cloudformation/
Apache License 2.0
142 stars 13 forks source link

Support JSON array in Parameters #48

Open akunszt opened 4 years ago

akunszt commented 4 years ago

1. Title

Support JSON array in Parameters

2. Scope of request

Using CommaDelimitedList is cumbersome when you have a lot and long entries. In example this is how one of our Parameter looks like - it lists some roles with full ARNs which can assume a role in this template:

[
        {
                "ParameterKey": "Roles",
                "ParameterValue": "arn:aws:iam::<ACCOUNT ID>:role/hack-k8s-ControllerRole-R15SAIGDYPU9,arn:aws:iam::<ACCOUNT ID>:role/hack-k8s-WorkerRole-1515LCTMRCU97,arn:aws:iam::<ACCOUNT ID>:role/hack-etcd-core-Role-VZQJPNX83BD4,arn:aws:iam::<ACCOUNT ID>:role/tools-k8s-ControllerRole-1VSO5HCE5Y4GT,arn:aws:iam::<ACCOUNT ID>:role/tools-k8s-WorkerRole-S5TPOAH3QSTT,arn:aws:iam::<ACCOUNT ID>:role/tools-etcd-core-Role-1K3R4EB7FPALR"
        }
]

It's very hard to handle this. It's very hard to check the diffs. And it's not even the final version it should be longer.

3. Expected behavior

We would like to use a JSON array to handle the CommaDelimitedList. The old behaviour can and should be maintained but the CloudFormation can join the value using , as a separator if it's an Array, not a String.

In example:

[
        {
                "ParameterKey": "Roles",
                "ParameterValue": [
                        "arn:aws:iam::<ACCOUNT ID>:role/hack-k8s-ControllerRole-R15SAIGDYPU9",
                        "arn:aws:iam::<ACCOUNT ID>:role/hack-k8s-WorkerRole-1515LCTMRCU97",
                        "arn:aws:iam::<ACCOUNT ID>:role/hack-etcd-core-Role-VZQJPNX83BD4",
                        "arn:aws:iam::<ACCOUNT ID>:role/tools-k8s-ControllerRole-1VSO5HCE5Y4GT",
                        "arn:aws:iam::<ACCOUNT ID>:role/tools-k8s-WorkerRole-S5TPOAH3QSTT",
                        "arn:aws:iam::<ACCOUNT ID>:role/tools-etcd-core-Role-1K3R4EB7FPALR"
                ]
        }
]

It's easier to read and compare two versions to spot a difference. The Parametes should be work as a CommaDelimitedList, so in the template the Ref should return as Array as before and you can use Fn::Select to access a specific element.

Also it would be very nice if the List<something> types also supports this behaviour.

4. Suggest specific test cases

See the Expected behavior chapter.

5. Helpful Links to speed up research and evaluation

N/A

6. Category

Other

lejiati commented 2 years ago

@akunszt Thank you very much for your feedback! Since this repository is focused on resource coverage, I'm transferring this issue over to a new GitHub repository dedicated to CloudFormation template language issues.

dgard1981 commented 2 years ago

In my opinion, not just arrays but objects and real Booleans should also be supported.