ECS Task Definition container_definitions is invalid: Error decoding JSON: invalid character 'f' after object key:value pair - terraform-provider-aws

I´m getting: [Error] invalid character 'f' after object key:value pair How can I tell what is the (f) that is causing the error? is not quite descriptive the output like in some other languages that tells you the line number at least.
{
"name": "${name}",
"ulimits": [
{
"name": "nofile",
"hardLimit": 204800,
"softLimit": 102400
}
],
"image": "${ecr_url}/${image_name}:${image_tag}",
"cpu": "${container_cpu}",
"memory": null,
"memoryReservation": "${container_memory}",
"command": [
"/bin/sh",
"-c",
"export DD_AGENT_HOST=$(curl --silent http://169.254.169.254/latest/meta-data/local-ipv4); /usr/bin/$APPLICATION_ARTIFACTS"
],
"essential": true,
"mountPoints": [],
"portMappings": [
{
"containerPort": "${container_port}",
"hostPort": 0,
"protocol": "tcp"
}
],
"volumesFrom": [],
"dockerLabels": {
"application": "${application}",
"environment": "${environment}",
"version": "${image_tag}"
},
"logConfiguration": {
"logDriver": "${log_driver}",
"options": "${log_configuration}"
},
"environment": [
{
"name": "AWS_REGION",
"value": "${task_region}"
},
{
"name": "APPLICATION_ARTIFACTS",
"value": "${application_artifacts}"
},
{
"name": "ENVIRONMENT",
"value": "${environment}"
},
{
"name": "VERSION",
"value": "${image_tag}"
},
{
"name": "SERVER_PORT",
"value": "${container_port}"
},
{
"name": "DD_TRACE_SAMPLE_RATE",
"value": "1.0"
},
{
"name": "DD_LOGS_INJECTION",
"value": "false"
},
{
"name": "DD_ENV",
"value": "${DD_ENV}"
},
{
"name": "DD_SERVICE",
"value": "${DD_SERVICE}"
},
{
"name": "TABLE_NAME",
"value": "${table_name}"
}
]
}
I´m getting: [Error] invalid character 'f' after object key:value pair
How can I tell what is the (f) that is causing the error? is not quite descriptive the output like in some other languages that tells you the line number at least.
Error: ECS Task Definition container_definitions is invalid: Error decoding JSON: invalid character 'f' after object key:value pair
on deployment/terraform/service-blue.tf line 89, in resource "aws_ecs_task_definition" "default_blue":
89: container_definitions = local.require_blue_service ? data.aws_s3_object.container_definition_blue[0].body : data.template_file.container_definitions.rendered

Related

Simplify array of objects with children using JQ

From Wikidata, I get the following json:
# Sparql query
query=$(cat ./myquery.sparql)
response=$(curl -G --data-urlencode query="${query}" https://wikidata.org/sparql?format=json)
echo "${response}" | jq '.results.bindings'
[
{
"language": {
"type": "uri",
"value": "https://lingualibre.org/entity/Q100"
},
"wikidata": {
"type": "literal",
"value": "Q36157"
},
"code": {
"type": "literal",
"value": "lub"
}
},
{
"language": {
"type": "uri",
"value": "https://lingualibre.org/entity/Q101"
},
"wikidata": {
"type": "literal",
"value": "Q36284"
},
"code": {
"type": "literal",
"value": "srr"
}
}
]
I would like to have the keys directly paired with their values, such as :
[
{
"language": "https://lingualibre.org/entity/Q100",
"wikidata": "Q36157",
"iso": "lub"
},
{
"language": "https://lingualibre.org/entity/Q101",
"wikidata": "Q36284",
"iso": "srr"
}
]
I currently have a non-resilient code, which will break whenever the key names change :
jq 'map({"language":.language.value,"wikidata":.wikidata.value,"iso":.code.value})'
How to pair the keys with their values in a resilient way (not naming the keys) ?
I want to "prune" the child objects so to only keep the value.
You could use map_values which works like the outer map but for objects, i.e. it retains the object structure, including the field names:
jq 'map(map_values(.value))'
[
{
"language": "https://lingualibre.org/entity/Q100",
"wikidata": "Q36157",
"code": "lub"
},
{
"language": "https://lingualibre.org/entity/Q101",
"wikidata": "Q36284",
"code": "srr"
}
]
Note that this solution lacks the name conversion from code to iso.

How to use ObjectSizeGreaterThan and ObjectSizeLessThan xml tags for AWS S3 command 'PutBucketLifeCycleConfiguration"?

Trying with a json input like this:
{
"Rules": [
{
"Expiration": {
"Date": "2023-01-01T00:00:00.000Z"
},
"ID": "id1",
"Filter": {
"And": {
"Tags": [
{
"Key": "k1",
"Value": "k1val1"
},
{
"Key": "k1u",
"Value": "k1vadl1"
}
],
"ObjectSizeGreaterThan": 100,
"ObjectSizeLessThan": 1000
}
},
"Status": "Enabled"
}
]
}
However, I am getting an error like this from the aws client:
Parameter validation failed:
Unknown parameter in LifecycleConfiguration.Rules[0].Filter.And: "ObjectSizeGreaterThan", must be one of: Prefix, Tags
Any idea why I get this error and how to correct it?
This seems to be working but only with the latest cli version aws-cli/2.7.30
I am getting the same error on aws-cli/1.19.39
{
"Rules": [
{
"Expiration": {
"Date": "2024-01-01T00:00:00.000Z"
},
"ID": "123",
"Filter": {
"And": {
"Prefix": "sricli",
"Tags": [
{
"Key": "ke",
"Value": "k1"
},
{
"Key": "je",
"Value": "k2"
}
],
"ObjectSizeGreaterThan": 102400,
"ObjectSizeLessThan": 204800
}
},
"Status": "Enabled"
}
]
}
Sri

Remove Quotation from HTTP reponse(string datatype) to pass in post API

I have an API returning data(string format) like this
84, 101, 115, 116
But when I call this in power automate the response I get thru HTTP post is with quotation marks
"84, 101, 115, 116"
Is there any way I can get it without quotation mark " ", As I need the output to send in another API which fails if I send it
with "".
The reason being it needs to pass the response to another API that accepts byte array
like this [84, 101, 115, 116]
currently, inflow it is being sent as ["84, 101, 115, 116"] which fails the API
I tried replace function but it doesn't work for my case.
I think you need to split up your texts into an array.
Start with initialising three variables as shown below ...
... as you can see, I initialised a string variable with your values, it doesn't show the quotes but it's declared as a string so when it treats it, the quotes will be there.
In the next steps, I initialise an array variable that has the following expression ...
split(replace(variables('Response'), ' ', ''), ',')
... and then a blank array that will store the resulting number values.
After the above, loop through each value that was found and add it to the number array, this will convert the value as a string to a numeric value.
The expression above is ... int(item())
That then produces this result and it's that array that can then be passed through to your next API call.
This is the JOSN definition that you can load into your own tenant to see the answer in its entirety.
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"For_each": {
"actions": {
"Append_to_array_variable": {
"inputs": {
"name": "Number Array",
"value": "#int(item())"
},
"runAfter": {},
"type": "AppendToArrayVariable"
}
},
"foreach": "#variables('String Array')",
"runAfter": {
"Initialize_Number_Array": [
"Succeeded"
]
},
"runtimeConfiguration": {
"concurrency": {
"repetitions": 1
}
},
"type": "Foreach"
},
"Initialize_Number_Array": {
"inputs": {
"variables": [
{
"name": "Number Array",
"type": "array"
}
]
},
"runAfter": {
"Initialize_String_Array": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_String_Array": {
"inputs": {
"variables": [
{
"name": "String Array",
"type": "array",
"value": "#split(replace(variables('Response'), ' ', ''), ',')"
}
]
},
"runAfter": {
"Initialize__Response": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize__Response": {
"inputs": {
"variables": [
{
"name": "Response",
"type": "string",
"value": "84, 101, 115, 116"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "Result",
"type": "array",
"value": "#variables('Number Array')"
}
]
},
"runAfter": {
"For_each": [
"Succeeded"
]
},
"type": "InitializeVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Month",
"interval": 12
},
"recurrence": {
"frequency": "Month",
"interval": 12
},
"type": "Recurrence"
}
}
},
"parameters": {}
}

Write r GET query from data provided

I have JSON data about R request that i need to write with necessary url, access token, parameters and other things, which must be included in httr query. I got it from getpostman item. Here it is:
{
"name": "GET /tablesbyquery",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "hnjP4YUF-woR0jhUyJIByeOI_q8jF99jK5WlQ", #fake for example
"type": "string"
}
]
},
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://somesource.os-pub.com/tables/tablesbyquery?timePeriod=actual&sort=utdDate,asc&query=&isNotEmptyStatus=false&size=20&page=0&providerId=",
"protocol": "http",
"host": [
"somesource",
"os-pub",
"com"
],
"path": [
"tables",
"tablesbyquery"
],
"query": [
{
"key": "timePeriod",
"value": "actual"
},
{
"key": "sort",
"value": "utdDate,asc"
},
{
"key": "query",
"value": ""
},
{
"key": "isNotEmptyStatus",
"value": "false"
},
{
"key": "size",
"value": "20"
},
{
"key": "page",
"value": "0"
},
{
"key": "providerId",
"value": ""
}
]
}
},
"response": []
}
I need to write R request query to GET necessary data. How it should look like? Im new in url and i have written this part:
url <- "http://somesource.os-pub.com/tables/tablesbyquery?timePeriod=actual&sort=utdDate,asc&query=&isNotEmptyStatus=false&size=20&page=0&providerId="
access_token <- "hnjP4YUF-woR0jhUyJIByeOI_q8jF99jK5WlQ"
res <- GET(url, access_token)
content(res, "parsed")
But it doesn't work.

Why is this pact-jvm provider test failing?

We’ve got a provider test that is only failing on Jenkins, which is preventing me from debugging.
Here are some relevant logs from Jenkins:
Error Message
0 - $.body.2 -> Expected name='FXUHHqWrZZcodhHBmeLf' but was missing
0) a request to get all clients returns a response which has a matching body
$.body.2 -> Expected name='FXUHHqWrZZcodhHBmeLf' but was missing
Diff:
(some ommissions…)
#10
],
- "id": "c53927c3-0d1c-48a8-8f0a-7560be89daa5",
- "name": "FXUHHqWrZZcodhHBmeLf",
+ "id": "9daaad0a-8a2d-4e73-a963-fa1625cec110",
+ "name": "name",
+ "privileges": [
+ "CHECK_TOKEN",
+ "MANAGE_CLIENT",
+ "MANAGE_IDP",
+ "MANAGE_USER"
+ ],
"redirectUris": [
And the interaction looks like this in the pact file:
{
"description": "a request to get all clients",
"request": {
"method": "GET",
"path": "/some/url/client"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json; charset=UTF-8"
},
"body": [
{
"accessTokenValiditySeconds": 42721462,
"allowedScopes": [
"JnTfAlnHKVSDzoWnUqZv"
],
"autoApprove": true,
"grantTypes": [
"VfWudsTQINERQCnVKvoK"
],
"id": "c53927c3-0d1c-48a8-8f0a-7560be89daa5",
"name": "FXUHHqWrZZcodhHBmeLf",
"redirectUris": [
"vWxSTjgJQvwUtwphDGcn"
],
"refreshTokenValiditySeconds": 12393550,
"secretRequired": true
}
],
"matchingRules": {
"$.body[*].allowedScopes[*]": {
"match": "type"
},
"$.body[*].redirectUris[*]": {
"match": "type"
},
"$.body[*].grantTypes[*]": {
"match": "type"
},
"$.body[*].redirectUris": {
"min": 0,
"match": "type"
},
"$.body[*].autoApprove": {
"match": "type"
},
"$.body": {
"min": 1,
"match": "type"
},
"$.body[*].id": {
"regex": "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
},
"$.body[*].accessTokenValiditySeconds": {
"match": "integer"
},
"$.body[*].secretRequired": {
"match": "type"
},
"$.body[*].refreshTokenValiditySeconds": {
"match": "integer"
},
"$.body[*].name": {
"match": "type"
},
"$.body[*].allowedScopes": {
"min": 0,
"match": "type"
},
"$.body[*].grantTypes": {
"min": 0,
"match": "type"
}
}
},
"providerState": "the 'zero' client exists"
},
I'm under the impression that the name should be matching on type instead of the exact value, and it appears that there is a "name" field in the diff.
Why is this test failing?
edit:
This is the code to produce the pact fragment:
builder
.given("the 'zero' client exists")
.uponReceiving("a request to get all clients")
.path("/some/url/client")
.method("GET")
.willRespondWith()
.status(200)
.body(PactDslJsonArray
.arrayMinLike(1)
.uuid("id")
.booleanType("secretRequired")
.eachLike("allowedScopes", stringType())
.eachLike("grantTypes", stringType())
.eachLike("redirectUris", stringType())
.integerType("accessTokenValiditySeconds")
.integerType("refreshTokenValiditySeconds")
.booleanType("autoApprove")
.stringType("name")
.closeObject())
.toFragment();
The important bit of information in the logs is the 'but was missing' bit. It seems to indicate that the third item in the array (matched by '$.body.2') was missing the name attribute.
Can you double check the full response, and if there is a name attribute in the third item, then could you kindly raise an issue at https://github.com/DiUS/pact-jvm.

Resources