4

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?

Angel Hadzhiev
  • 664
  • 2
  • 6
  • 20
  • I'd check a couple of things: 1) make sure you have the latest version of awscli and 2) try this operation using the AWS Console, supplying the same policy name (does it work?) – jarmod Oct 13 '21 at 01:38

3 Answers3

5

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.

Angel Hadzhiev
  • 664
  • 2
  • 6
  • 20
2

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
Yvette Lau
  • 191
  • 1
  • 7
0

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

Sehrish Waheed
  • 1,230
  • 14
  • 17