aws / aws/aws-cli

AllowedPattern broken with CommaDelimitedList parameter

Open
#9,030 11 comments 1 reaction 0 assignees View on GitHub
bug cloudformation documentation p2 service-api
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### Describe the bug

I have an AWS CloudFormation template with the following parameter:

```yaml
Profiles:
Description: The comma-separated list of active profiles, such as "dev,test".
Type: CommaDelimitedList
Default: ""
AllowedPattern: '\w+'
ConstraintDescription: Active profile identifiers must only use word characters, separated by commas.
```

The [latest documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html) for `AllowedPattern` says:

> When applied to a parameter of type `CommaDelimitedList`, the pattern must match each value in the list.

I try to invoke `aws cloudformation deploy …` passing the `Profiles` parameter:

```bash
aws cloudformation deploy … --parameter-overrides … Profiles=dev,test
```

This doesn't work either:

```bash
aws cloudformation deploy … --parameter-overrides … Profiles="dev,test"
```

In fact even this doesn't work!

```bash
aws cloudformation deploy … --parameter-overrides … Profiles=dev
```

The AWS CLI tells me:

> `An error occurred (ValidationError) when calling the CreateChangeSet operation: Parameter Profiles failed to satisfy constraint: Active profile identifiers must only use word characters, separated by commas.`

If I remove `AllowedPattern`, it works:

```yaml
Profiles:
Description: The comma-separated list of active profiles, such as "dev,test".
Type: CommaDelimitedList
Default: ""
# AllowedPattern: '\w+'
ConstraintDescription: Active profile identifiers must only use word characters, separated by commas.
```

If I switch to PowerShell and try this, it fails as well:

```powershell
aws cloudformation deploy … --parameter-overrides … Profiles=dev,test
```

This fails, too, in PowerShell:

```powershell
aws cloudformation deploy … --parameter-overrides … 'Profiles=dev'
```

And this fails, too, in PowerShell:

```powershell
aws cloudformation deploy … --parameter-overrides '… Profiles=dev'
```

### Expected Behavior

I expected the value `dev,test` to be assigned to the `Profiles` parameter, exactly has happens if I remove the `AllowedPattern` from the template.

### Current Behavior

The CLI tells me:

> `An error occurred (ValidationError) when calling the CreateChangeSet operation: Parameter Profiles failed to satisfy constraint: Active profile identifiers must only use word characters, separated by commas.

Add the following parameter to a CloudFormation template:

```yaml
Parameters:
Profiles:
Description: The comma-separated list of active profiles, such as "dev,test".
Type: CommaDelimitedList
Default: ""
AllowedPattern: '\w+'
ConstraintDescription: Active profile identifiers must only use word characters, separated by commas.
```

### Reproduction Steps

```bash
aws cloudformation deploy--stack-name foo --template-file bar.yaml --parameter-overrides Profiles=dev,test
```

### Possible Solution

It works if I remove `AllowedPattern` from the CloudFormation template.

### Additional Information/Context

I have tried it with two CLI versions in three shells:
* WSL Ubunutu: `aws-cli/2.11.0 Python/3.11.2 Linux/5.15.90.1-microsoft-standard-WSL2 exe/x86_64.ubuntu.22 prompt/off`
* Git Bash: `aws-cli/2.9.21 Python/3.9.11 Windows/10 exe/AMD64 prompt/off`
* PowerShell: `aws-cli/2.9.21 Python/3.9.11 Windows/10 exe/AMD64 prompt/off`

### CLI version used

aws-cli/2.11.0 Python/3.11.2 Linux/5.15.90.1-microsoft-standard-WSL2 exe/x86_64.ubuntu.22 prompt/off

### Environment details (OS name and version, etc.)

Windows 10

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.