0

I am registering patch baseline with Patch Group by AWS CLI and I am getting an error as mentioned in the subject.

Command used to create a Patch baseline is below:

baselineid=$(aws ssm create-patch-baseline --name "Test-NonProd-Baseline" --operating-system "WINDOWS" --tags "Key=Environment,Value=Production" --approval-rules "PatchRules=[{PatchFilterGroup={PatchFilters=[{Key=MSRC_SEVERITY,Values=[Critical,Important]},{Key=CLASSIFICATION,Values=[SecurityUpdates,Updates,ServicePacks,UpdateRollups,CriticalUpdates]}]},ApproveAfterDays=7}]" --description "Baseline containing all updates approved for production systems" --query BaselineId)

I used then above id to register patch baseline with patch group as like below

aws ssm register-patch-baseline-for-patch-group --baseline-id $baselineid --patch-group "Group A"

Unfortunately, I get the error below:

An error occurred (ValidationException) when calling the RegisterPatchBaselineForPatchGroup operation: 1 validation error detected: Value '"pb-08a507ce98777b410"' at 'baselineId' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-zA-Z0-9_\-:/]{20,128}$.

Note: Even if I use double quotes around "$baslineid" still I do get the same error.

Variable $baselineid has a valid value, please see below:

[ec2-user@ip-172-31-40-59 ~]$ echo $baselineid
"pb-08a507ce98777b410"

Want to understand what is the issue when I'm getting a legit value and how to have it resolved.

learner
  • 2,480
  • 10
  • 50
  • 94

1 Answers1

1

You can perhaps use this in your second command, basically using tr utility to truncate the double qoutes:

echo $baselineid| tr -d '"'

The solution to the double quote issue has many possible fixes in this SO post:

Shell script - remove first and last quote (") from a variable

So a possible solution command could be something like this:

aws ssm register-patch-baseline-for-patch-group --baseline-id $(echo $baselineid| tr -d '"') --patch-group "Group A"
mk_gocs
  • 58
  • 6
  • Thanks a lot, Sir, never though that double quotes would be causing an issue. Works as expected. – learner Jun 27 '20 at 06:54