Angel Hadzhiev
Angel Hadzhiev

Reputation: 966

failed to satisfy constraint: Member must satisfy regular expression pattern: [\w+=,.@-]+

I am trying to apply a policy for an identity pool in AWS. I am using awc-cli to set up the policy but it constantly gives me this exception from the title:

An error occurred (InvalidRequestException) when calling the AttachPrincipalPolicy operation: 1 validation error detected: Value ''DeviceShadowPolicy'' at 'policyName' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w+=,.@-]+

This is the command I use:

aws iot attach-principal-policy --policy-name 'DeviceShadowPolicy' --principal 'PRINCIPAL'

I do not understand why do I get this error. Could somebody help me out?

Upvotes: 14

Views: 63690

Answers (4)

Stylianos Nikas
Stylianos Nikas

Reputation: 83

Had a similar issue with a document with special characters in its title (specifically ü). After removing special characters everything worked ok.

Upvotes: 0

Sehrish Waheed
Sehrish Waheed

Reputation: 1555

There was a space in client id in my url make sure there is no client_id="%203434..." should be client_id="3434..."

Upvotes: 0

Yvette Lau
Yvette Lau

Reputation: 441

I have this issues when I m using aws cli inside the bash script

The error I has was

An error occurred (ValidationException) when calling the DescribeCertificate operation: 1 validation error detected: Value '"arn:aws:acm:us-east-1:xxxxxxxxxx:certificate/6... (truncated)' at 'certificateArn' failed to satisfy constraint: Member must satisfy regular expression pattern: arn:[\w+=/,.@-]+:acm:[\w+=/,.@-]*:[0-9]+:[\w+=,.@-]+(/[\w+=,.@-]+)*

it turn out the variable I save from the output has double quote which can't be used for the next aws cli

The solution are below:

  1. Try to use --query and --output text when you are suing AWS CLI, it will get the value without the double quote.
  2. Remove the double quote from the script
ARN='"arn:aws:acm:us-east-1:xxxxxxxxxx:certificate/aaaaaaa-bbbbb-ccccc-dddd-fffffffffff"'

echo "${ARN//\"/}"

## Output: arn:aws:acm:us-east-1:xxxxxxxxxx:certificate/aaaaaaa-bbbbb-ccccc-dddd-fffffffffff

Upvotes: 3

Angel Hadzhiev
Angel Hadzhiev

Reputation: 966

Apparently, the answer was that it has to be without the single quotation sign. All the examples I saw had it with a quotation sign but for me it worked without.

Hopefully, that helps somebody.

Upvotes: 10

Related Questions