Getting this error when creating SSM document: invalidDocumentContent: YAML not well-formed.
This is the line below that the error references
"$version = '6.18'",
I get the same error on other lines in the new block, so if I can figure out this line, I can figure out the rest too.
I cloned a working SSM document and put this block of code in. The document works fine besides this block. I'm just perplexed, and I am sure this is due to my inexperience and the answer is simple and I will feel stupid when it's revealed...
Document:
{
"schemaVersion": "2.2",
"description": "X",
"parameters": {},
"mainSteps": [
{
"action": "aws:runPowerShellScript",
"name": "dbaCustomizations",
"precondition": {
"StringEquals": [
"platformType",
"Windows"
]
},
"inputs": {
"runCommand": [
"$errorActionPreference = 'stop'",
"try {",
"$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'",
"[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols",
"Set-ItemProperty -Path 'HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\.NetFramework\\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord",
"Set-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\.NetFramework\\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord",
"",
"# PG admin separately for the ALLUSERS flag for now. ",
"$version = '6.18'",
"$output = [string]::Format('C:\pgadmin4-{0}-x64.exe',$version)",
"$url = [string]::Format('https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v{0}/windows/pgadmin4-{0}-x64.exe',$version)",
"(New-Object Net.WebClient).DownloadFile($url, $output)",
"Start-Process -Wait -FilePath $output -ArgumentList '/ALLUSERS /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' -PassThru",
"}",
"} catch",
"{",
" Write-Output \"Error encountered \" + $Error[0].Exception.Message",
" exit 1",
"}",
""
],
"timeoutSeconds": 7200
}
}
]
}
Related
The az webapp identity show command: https://learn.microsoft.com/en-us/cli/azure/webapp/identity?view=azure-cli-latest#az-webapp-identity-show
Will return the following result:
{
"principalId": null,
"tenantId": null,
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx": {
"clientId": "xxx",
"principalId": "xxx"
}
}
}
Now I am only intrested in returning the /subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxx value. How can I filter this value using --query option? I have tried
--query userAssignedIdentities
"/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx": {
"clientId": "xxx",
"principalId": "xxx"
}
}
But there is something more required to get the first key here. What?
Use the below Azure CLI cmdlet
az webapp identity show -name <WebAppName> -g <ResoureGroupName> --query "keys(userAssignedIdentities)" -o tsv
Alternatively, you can use the below PowerShell cmdlet to pull the resourceId of the userAssignedIdentities that is assigned to Azure web app.
$identity=Get-AzWebApp -Name <WebAppName> -ResourceGroupName "<ResourceGroupName>" | select -ExpandProperty Identity
$identity.UserAssignedIdentities.Keys
I've been trying to fix this bug and I haven't been able to figure it out. I know this is similar to some of the other threads I've seen on here but I've verified it's not a typo and that the issue isn't with an incorrect data type. Would really appreciate the help and for someone to point out what i'm missing here. Thanks!
Edit: Here's the stack trace
{
"errors": [
{
"message": "Syntax Error: Expected Name, found Int \"-12\".",
"locations": [
{
"line": 8,
"column": 27
}
],
"extensions": {
"code": "GRAPHQL_PARSE_FAILED",
"exception": {
"stacktrace": [
"GraphQLError: Syntax Error: Expected Name, found Int \"-12\".",
" at syntaxError (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/error/syntaxError.js:15:10)",
" at Parser.expectToken (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:1413:40)",
" at Parser.parseName (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:98:22)",
" at Parser.parseObjectField (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:591:21)",
" at Parser.item (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:575:21)",
" at Parser.any (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:1485:26)",
" at Parser.parseObject (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:580:20)",
" at Parser.parseValueLiteral (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:461:21)",
" at Parser.item (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:553:20)",
" at Parser.any (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:1485:26)"
]
}
}
}
]
}
You have creationTime as a string without quotes, so you need quotes
change it to this:
creationTime: "2007-12-03R10:15:30Z",
I have a file like below. As you can see there are few lines/contents between curly braces. As there is multiple group of opened and closed curly braces, I want to get the content between the curly brances ({ and } ) for each line separatly.
Sample file:
{
"/tmp/©ƒ-4bf57ed2-velero/velero/templates/crds.yaml": [
],
"/tmp/velero-4bf57ed2-velero/velero/templates/deployment.yaml": [
],
"/tmp/velero-4bf57ed2-velero/velero/templates/restic-daemonset.yaml": [
],
"/tmp/velero-4bf57ed2-velero/velero/templates/secret.yaml": [
]
}
{
"/tmp/autoscaler-fb12fa7a-cluster-autoscaler/cluster-autoscaler/templates/deployment.yaml": [
".spec.replicas: '2' != '0'",
],
"/tmp/autoscaler-fb12fa7a-cluster-autoscaler/cluster-autoscaler/templates/servicemonitor.yaml": [
"error: the server doesn't have a resource type \"ServiceMonitor\"\n"
]
}
{
"/tmp/metrics-server-1960953a-metrics-server-certs/raw/templates/resources.yaml": [
"error: the server doesn't have a resource type \"Issuer\"\n",
"error: the server doesn't have a resource type \"Certificate\"\n"
]
}
Expected result: Need 3 seperated data chunks which is between the curly braces.
Could someone help me here?
If you have a sequence of valid JSON objects, you can use jq to easily and robustly process them:
Given file.jsons:
{
"/tmp/©ƒ-4bf57ed2-velero/velero/templates/crds.yaml": [ ""
],
"/tmp/velero-4bf57ed2-velero/velero/templates/deployment.yaml": [ ""
],
"/tmp/velero-4bf57ed2-velero/velero/templates/restic-daemonset.yaml": [ ""
],
"/tmp/velero-4bf57ed2-velero/velero/templates/secret.yaml": [ ""
]
}
{
"/tmp/autoscaler-fb12fa7a-cluster-autoscaler/cluster-autoscaler/templates/deployment.yaml": [
".spec.replicas: '2' != '0'"
],
"/tmp/autoscaler-fb12fa7a-cluster-autoscaler/cluster-autoscaler/templates/servicemonitor.yaml": [
"error: the server doesn't have a resource type \"ServiceMonitor\"\n"
]
}
{
"/tmp/metrics-server-1960953a-metrics-server-certs/raw/templates/resources.yaml": [
"error: the server doesn't have a resource type \"Issuer\"\n",
"error: the server doesn't have a resource type \"Certificate\"\n"
]
}
You can for example reformat each object as a single line:
$ jq -s -r 'map(#json) | join("\n")' < file.jsons
{"/tmp/©ƒ-4bf57ed2-velero/velero/templates/crds.yaml":[""],"/tmp/velero-4bf57ed2-velero/velero/templates/deployment.yaml":[""],"/tmp/velero-4bf57ed2-velero/velero/templates/restic-daemonset.yaml":[""],"/tmp/velero-4bf57ed2-velero/velero/templates/secret.yaml":[""]}
{"/tmp/autoscaler-fb12fa7a-cluster-autoscaler/cluster-autoscaler/templates/deployment.yaml":[".spec.replicas: '2' != '0'"],"/tmp/autoscaler-fb12fa7a-cluster-autoscaler/cluster-autoscaler/templates/servicemonitor.yaml":["error: the server doesn't have a resource type \"ServiceMonitor\"\n"]}
{"/tmp/metrics-server-1960953a-metrics-server-certs/raw/templates/resources.yaml":["error: the server doesn't have a resource type \"Issuer\"\n","error: the server doesn't have a resource type \"Certificate\"\n"]}
Now you can process it line by line without having to worry about matching up curly braces.
Thank you for your suggestion, the above jq would not work for all the json payload . For example for below json payload it is giving an error
{
"/tmp/ingress-dae7bd30-ingress-internet/nginx-ingress/templates/controller-deployment.yaml": [
".spec.replicas: '2' != '3'",
],
"/tmp/ingress-dae7bd30-ingress-internet/nginx-ingress/templates/controller-metrics-service.yaml": [
".spec.clusterIP: '' != '10.3.24.53'"
],
"/tmp/ingress-dae7bd30-ingress-internet/nginx-ingress/templates/controller-service.yaml": [
".spec.clusterIP: '' != '10.3.115.118'"
],
"/tmp/ingress-dae7bd30-ingress-internet/nginx-ingress/templates/controller-stats-service.yaml": [
".spec.clusterIP: '' != '10.3.115.30'"
],
"/tmp/ingress-dae7bd30-ingress-internet/nginx-ingress/templates/default-backend-deployment.yaml": [
]
}
I want write script as Command Line in TeamCity for break my assembly. I using SonnarQube v: 7.....
My script is:
set PROJECTKEY="%sonar.proj.key%"
set QGSTATUS=`"%curl.exe%" -s -u
http://SONNAR_URL:9000/api/qualityates/project_status?projectKey=$PROJECTKEY
if "%%QGSTATUS%%" == "OK" exit 0
if "%%QGSTATUS%%" == "ERROR" exit 1
But request
http://SONNAR_URL:9000/api/qualityates/project_status?projectKey=$PROJECTKEY
return for example this message:
"projectStatus": {
"status": "ERROR",
"conditions": [
{
"status": "ERROR",
"metricKey": "new_security_rating",
"comparator": "GT",
"periodIndex": 1,
"errorThreshold": "1",
"actualValue": "5"
},
{
"status": "ERROR",
"metricKey": "new_reliability_rating",
"comparator": "GT",
"periodIndex": 1,
"errorThreshold": "1",
"actualValue": "3"
},
{
"status": "OK",
"metricKey": "new_maintainability_rating",
"comparator": "GT",
"periodIndex": 1,
"errorThreshold": "1",
"actualValue": "1"
},
But I need, that api requst return me only status "Failed" or Error.
It's necessary for break my assembly in TeamCity
Script from hear (Quality Gate Failure in SonarQube does not fail the build in Teamcity)
not working for me, maybe because I using SonnarQube v 7...
How write correct script for TeamCity or how write correct API request, that get one word - Error or Ok
I also had this problem and managed to solve with the example below.
Hope this helps!
You have to enter this code by creating a PowerShell step in Teamcity.
$QGSTATUS = curl.exe -s -u yourLogin:yourPassword http://YourSonarAPIQualityGate | jq '.projectStatus.status'
if ($QGSTATUS -eq "OK")
{
echo SUCCESS
exit 0
}
else
{
echo "QUALITY GATE SONAR ERROR"
exit 1
}
I have a response from aws like this
{
"Owner": {
"DisplayName": "2414218.aws",
"ID": "xxxxxxxx"
},
"Grants": [
{
"Grantee": {
"DisplayName": "2414218.aws",
"ID": "yyyyyyyyyy"
},
"Permission": "FULL_CONTROL"
},
{
"Grantee": {
"URI": "http://acs.amazonaws.com/groups/global/AllUsers"
},
"Permission": "READ"
}
]
}
I am looking to update the files so AllUsers is removed (get-object-acl should look like the below)
{
"Owner": {
"DisplayName": "2414218.aws",
"ID": "xxxxxxxx"
},
"Grants": [
{
"Grantee": {
"DisplayName": "2414218.aws",
"ID": "yyyyyyyyyy"
},
"Permission": "FULL_CONTROL"
}
]
}
How would I do this, not knowing what other grantees are available? I am specifically looking to remove a grantee when I see http://acs.amazonaws.com/groups/global/AllUsers
I am currently using aws s3api get-object-acl --bucket mhe-deployments-prod --key $keyFile | jq '.' to locate the policies
Here is a jq filter which will remove all the .Grants array elements for which .Grantee.URI is "http://acs.amazonaws.com/groups/global/AllUsers":
.Grants |= map( select(.Grantee.URI != "http://acs.amazonaws.com/groups/global/AllUsers") )
Output: as requested
You can do using the built in --query option in the AWS CLI. The benefit being you don't need any external tools:
aws s3api get-object-acl --bucket $BUCKET --key $KEY \
--query "{Owner: Owners, \
Grants: Grants[?Grantee.URI != 'http://acs.amazonaws.com/groups/global/AllUsers']}"
Probably not the best but, this worked
#!/usr/local/bin/bash
# aws ~/.aws/credentials and s3cmd must be configured first with proper creds
target=''
for key in $(aws s3 ls s3://$target --recursive |awk '{print$4}') ; do
[ "${key: -1}" == "/" ] || {
award=$(aws s3api get-object-acl --bucket $target --key $key |jq '.Grants[].Grantee | .URI' |grep -v 'null' |grep AllUsers)
[ ! -z "${award}" ] && {
policy=$(aws s3api get-object-acl --bucket $target --key $key)
echo "$target: $key\n$policy\n\n" >> /tmp/policy-backup.json
echo -e "Working on: $key"
s3cmd setacl s3://$target/$key --acl-private ## s3cmd must be comfigured to your env
}
}
done
In this problem the specified grant can also be removed directly with del. e.g
del(
.Grants[]
| select(.Grantee.URI == "http://acs.amazonaws.com/groups/global/AllUsers")
)