ini file for cloudformation parameter file - configuration

We're gluing together cloud formation template .yaml files with boto3. My strong inclination is to use the .ini format for parameter and tag files because
.ini format is easier to read than either YAML or json
the python 'configparser' library supports a 'default' section
which will reduce typing a lot.
Two possible disadvantages to this approach are:
native .ini doesn't support lists
We might want to feed the parameter files to the aws cli
There are a bunch of ways to extend configparser, the standard python library for handling ini files to handle lists.
I don't think we will want or need to feed yaml to the aws cli and converting ini to YAML doesn't seem hard.
What disadvantage of ini am I missing ?
For comparison same file in ini / yaml / json
; ini
[default]
KeyPairName = MyKey
InstanceType = m1.micro
# YAML
---
- ParameterKey: KeyPairName
ParameterValue: MyKey
- ParameterKey: InstanceType
ParameterValue: m1.micro
json:
[
{
"ParameterKey": "KeyPairName",
"ParameterValue": "MyKey"
},
{
"ParameterKey": "InstanceType",
"ParameterValue": "m1.micro"
}
]

You can bypass the problem of .ini not handling list with parameters of type CommaDelimitedList. Considering you only want to use the .ini for parameters and tags, I don't foresee issues of doing this.

Related

Add data to a json file in terraform

I am not a software guy, but I am preparing a small script for delarative onboarding work using terraform. The declaration is in a json file and it is send to the device through terraform. But I do not want to keep the sensitive data like passwords and secret keys in the json file. I want to inject them from a seperate file in a vault to the json file when I am executing it in terraform. I can use terraform to read the data from a vault or a s3 bucket, but I am not sure how to add it to the json declaration. I saw in terraform there is a functions like jsondecode and jsonencode. But I am not sure whether they will be any use to my requirement.
Could someone help me on this please ?
Thansk.
Maybe this is something which could help you?
Create a data source which loads your template file, here you can pass in some vars.
some examples for variales:
data "template_file" "my_template" {
template = templatefile("template.json", {
foo = "bar"
another_foo = aws_s3_bucket.my_bucket.id
more_foo = var.my_variable
})
}
The template file could look like this:
{
"Value": "123",
"value_2": "${foo}",
"value_3": "${another_foo}",
"value_4": ${more_foo},
}

What is the practical different between the usage of JSON and YAML in Swagger?

It appears that JSON includes the path information and http request verb, whereas YAML seems to just definition a tree structure alone.
What is the difference between them? Or am I mixing up different concepts/hierarchies here? newbie to swagger, just started learning.
If YAML is a superset of JSON what specifically is the superset adding here - is it URL paths and HTTP verbs ? Is adding an example also something that YAML adds to JSON for Swagger ?
According to the OpenAPI Specification,
An OpenAPI document that conforms to the OpenAPI Specification is itself a JSON object, which may be represented either in JSON or YAML format.
So feature-wise, there is no difference between using JSON or YAML. What YAML as a superset of JSON adds here is merely a different syntax. Using an example from the specification, these two documents are identical:
{
"servers": [
{
"url": "https://development.gigantic-server.com/v1",
"description": "Development server"
},
{
"url": "https://staging.gigantic-server.com/v1",
"description": "Staging server"
},
{
"url": "https://api.gigantic-server.com/v1",
"description": "Production server"
}
]
}
and
servers:
- url: https://development.gigantic-server.com/v1
description: Development server
- url: https://staging.gigantic-server.com/v1
description: Staging server
- url: https://api.gigantic-server.com/v1
description: Production server
The first document is valid JSON and valid YAML (since YAML is a superset of JSON). The second document is valid YAML and structurally identical to the first document.
So to answer the question about what the YAML superset adds here: It adds different syntax for specifying the same structures. Nothing more.
YAML does include some features that are not mappable to JSON, but they are irrelevant here because Swagger/OpenAPI doesn't use them.
JSON does not support comments, while YAML does!
YAML is neater, easier to read and write than JSON if you look at it from another angle.

JSON logfile into Solr via Apache nifi

I'm tring to read a json log file and insert into solr collection using apache nifi.logfile is in following format(one json object perline)
{"#timestamp": "2017-02-18T02:16:50.496+04:00","message": "hello"}
{"#timestamp": "2017-02-18T02:16:50.496+04:00","message": "hello"}
{ "#timestamp": "2017-02-18T02:16:50.496+04:00","message": "hello"}
I was able to load the file and split by lines using different processes. How can i proceed further ?
You can use the PutSolrContentStream processor to write content to Solr from Apache NiFi. If each flowfile contains a single JSON record (and you should ensure you are splitting the JSON correctly even if it covers multiple lines, so examine SplitJSON vs. SplitText), each will be written to Solr as a different document. You can also use MergeContent to write in batches and be more efficient.
Bryan Bende wrote a good article on the Apache site on how to use this processor.

Use swagger JSON api definition with different hostname and schemes

I want to use swagger with different hostnames but keep the same description file. How is this possible, For example, I tried an empty string for host and listed the schemes, but that did not work.
"host": "",
"schemes": [ "http" ],
Put markers like ${host} in your swagger definition file and process it with a template processor of your choice (perl script, Apache Velocity, Apache Freemarker, Maven resource processing, etc.).
An alternative approach that just came to my mind yet I have not tried myself involves using Postman extension for Google Chrome browser and its environmental variables. Postman can import swagger files into request collections and supports definition of environmental variables (see https://www.getpostman.com/docs/environments) for use in requests. Now, if you write the markers in the swagger definition file using the syntax notation of Postman and name those equal to your defined variables, you can keep requests and environment separated in Postman and you can change and reimport the swagger definitions anytime.
swagger.js has to be modified to accept host option. swagger-UI passes options to swagger-js and it accepts a 'spec' parameter.The hosting page can load the swagger.json file by simply parsing it as JSON.parse.
Set 'host' in it and then pass it to swaggerUi constructor.
I would like you to go through the link once.
Allow host to be specified
Hope it helps you in understanding.

Include a json file in an another json file only with json

In xml i can include a file in a another xml file and use it. This is usefull if your software get the configuration file from xml but doesn't have any method to separate configuration like apache/ngnix(nginx.conf - site-available/ - site-enable/).
file A:
<!DOCTYPE icecast [
<!ENTITY mount SYSTEM "mount.xml">
]>
<icecast>
...
&mount;
...
</icecast>
file B:
<mount>
<mount-name>/xyz</mount-name>
<username>source</username>
<password>password</password>
<max-listeners>30</max-listeners>
<hidden>0</hidden>
<public>1</public>
<no-yp>0</no-yp>
</mount>
But what if the configuration file is in json format? Is there a method equivalent?
I need to have a better organization of my couchbase-sync bucket configuration.
There is no mechanism in JSON for including another file, like you describe. JSON is not a language in the sense that XML is, it's just the JavaScript object notation, so it only serves to describe application objects, nothing else.