https://github.com/alistanis/cf_parameter_generator
Do you need to write a ton of CloudFormation? Is it annoying to have to type ParameterKey and ParameterValue a million times and copying the Parameter names into a parameters file? Well, now you don't have to.
https://github.com/alistanis/cf_parameter_generator
aws cloud cloudformation devops formation golang parameter
Last synced: about 1 month ago
JSON representation
Do you need to write a ton of CloudFormation? Is it annoying to have to type ParameterKey and ParameterValue a million times and copying the Parameter names into a parameters file? Well, now you don't have to.
- Host: GitHub
- URL: https://github.com/alistanis/cf_parameter_generator
- Owner: alistanis
- License: mit
- Created: 2017-02-14T21:49:49.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-27T17:01:30.000Z (almost 9 years ago)
- Last Synced: 2024-06-20T01:50:26.416Z (over 1 year ago)
- Topics: aws, cloud, cloudformation, devops, formation, golang, parameter
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 21
- Watchers: 3
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cf_parameter_generator
Do you need to write a ton of CloudFormation? Is it annoying to have to type ParameterKey and ParameterValue a million times and copying the Parameter names into a parameters file? Well, now you don't have to.
Get it: `go get -u github.com/alistanis/cf_parameter_generator ./...`
## Examples
Usage
cf_parameter_generator --help
Usage of cf_parameter_generator:
-f string
The file to read from to generate parameters.
-inyaml
Will expect input as yaml instead of json.
-min
If given, will generate minified output.
-o string
Optional: Specify a file name to write out parameters.
-outyaml
Will output in yaml instead of json.
-overwrite
By default, will update an existing parameters file with newly found parameters, but will not overwrite.
-r Removes old entries from parameters found in old parameters files.
-spaces int
The number of spaces used to indent the file if not generating minified output. (default 2)
-v Places verbose output in the ParameterValue field to be replaced.
-version
Print the version and exits.
Printing output to command line:
$ cf_parameter_generator -f test.json
```json
[
{
"ParameterKey": "AccessControl",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "ApplicationName",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "AssetID",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "Environment",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "LifecycleConfigurationStatus",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "NoncurrentVersionExpirationInDays",
"ParameterValue": "Type: Number"
},
{
"ParameterKey": "SubnetIDs",
"ParameterValue": "Type: List"
},
{
"ParameterKey": "VersioningConfigurationStatus",
"ParameterValue": "Type: String"
}
]
```
Accept input over stdin:
$ cat test.json | cf_parameter_generator
```json
[
{
"ParameterKey": "AccessControl",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "ApplicationName",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "AssetID",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "Environment",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "LifecycleConfigurationStatus",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "NoncurrentVersionExpirationInDays",
"ParameterValue": "Type: Number"
},
{
"ParameterKey": "SubnetIDs",
"ParameterValue": "Type: List"
},
{
"ParameterKey": "VersioningConfigurationStatus",
"ParameterValue": "Type: String"
}
]
```
Saving output to a new file (will update an existing file or overwrite it if it is blank (0 bytes))
$ cf_parameter_generator -f test.json -o params.json
Contents of file:
```json
[
{
"ParameterKey": "AccessControl",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "ApplicationName",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "AssetID",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "Environment",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "LifecycleConfigurationStatus",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "NoncurrentVersionExpirationInDays",
"ParameterValue": "Type: Number"
},
{
"ParameterKey": "SubnetIDs",
"ParameterValue": "Type: List"
},
{
"ParameterKey": "VersioningConfigurationStatus",
"ParameterValue": "Type: String"
}
]
```
Edit contents of file with real parameters:
```json
[
{
"ParameterKey": "AccessControl",
"ParameterValue": "Private"
},
{
"ParameterKey": "ApplicationName",
"ParameterValue": "TestApp"
},
{
"ParameterKey": "AssetID",
"ParameterValue": "1"
},
{
"ParameterKey": "Environment",
"ParameterValue": "dev"
},
{
"ParameterKey": "LifecycleConfigurationStatus",
"ParameterValue": "Enabled"
},
{
"ParameterKey": "NoncurrentVersionExpirationInDays",
"ParameterValue": "30"
},
{
"ParameterKey": "SubnetIDs",
"ParameterValue": "subnet-a3425f2,subnet-a34551f"
},
{
"ParameterKey": "VersioningConfigurationStatus",
"ParameterValue": "Enabled"
}
]
```
Add a new Parameter to a template called InstanceIDS and run cf_parameter_generator again:
$ cf_parameter_generator -f test.json -o params.json
New File Contents:
```json
[
{
"ParameterKey": "AccessControl",
"ParameterValue": "Private"
},
{
"ParameterKey": "ApplicationName",
"ParameterValue": "TestApp"
},
{
"ParameterKey": "AssetID",
"ParameterValue": "1"
},
{
"ParameterKey": "Environment",
"ParameterValue": "dev"
},
{
"ParameterKey": "InstanceIDs",
"ParameterValue": "Type: List"
},
{
"ParameterKey": "LifecycleConfigurationStatus",
"ParameterValue": "Enabled"
},
{
"ParameterKey": "NoncurrentVersionExpirationInDays",
"ParameterValue": "30"
},
{
"ParameterKey": "SubnetIDs",
"ParameterValue": "subnet-a3425f2,subnet-a34551f"
},
{
"ParameterKey": "VersioningConfigurationStatus",
"ParameterValue": "Enabled"
}
]
```
Overwrite Parameters File:
$ cf_parameter_generator -f test.json -o params.json -overwrite
```json
[
{
"ParameterKey": "AccessControl",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "ApplicationName",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "AssetID",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "Environment",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "InstanceIDs",
"ParameterValue": "Type: List"
},
{
"ParameterKey": "LifecycleConfigurationStatus",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "NoncurrentVersionExpirationInDays",
"ParameterValue": "Type: Number"
},
{
"ParameterKey": "SubnetIDs",
"ParameterValue": "Type: List"
},
{
"ParameterKey": "VersioningConfigurationStatus",
"ParameterValue": "Type: String"
}
]
```
Remove InstanceIDs from template and run again with -r:
$ cf_parameter_generator -f test.json -o params.json -r
Removing value {InstanceIDs Type: List [] }
File contents after removal:
```json
[
{
"ParameterKey": "AccessControl",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "ApplicationName",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "AssetID",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "Environment",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "LifecycleConfigurationStatus",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "NoncurrentVersionExpirationInDays",
"ParameterValue": "Type: Number"
},
{
"ParameterKey": "SubnetIDs",
"ParameterValue": "Type: List"
},
{
"ParameterKey": "VersioningConfigurationStatus",
"ParameterValue": "Type: String"
}
]
```
Print Verbose Output:
$ cf_parameter_generator -f test.json -v
```json
[
{
"ParameterKey": "AccessControl",
"ParameterValue": "Type: String, Default: Private, AllowedValues: [Private PublicRead PublicReadWrite AuthenticatedRead LogDeliveryWrite BucketOwnerRead BucketOwnerFullControl], Description: The ACL to apply to this S3 bucket."
},
{
"ParameterKey": "ApplicationName",
"ParameterValue": "Type: String, Description: The name of this application"
},
{
"ParameterKey": "AssetID",
"ParameterValue": "Type: String, Description: The HUIT asset ID for this application"
},
{
"ParameterKey": "Environment",
"ParameterValue": "Type: String, Default: dev, AllowedValues: [dev test int stage prod prod1 prod2], Description: The deployment environment for this application"
},
{
"ParameterKey": "InstanceIDs",
"ParameterValue": "Type: List, Description: Instance IDs"
},
{
"ParameterKey": "LifecycleConfigurationStatus",
"ParameterValue": "Type: String, Default: Enabled, AllowedValues: [Enabled Disabled], Description: Enables or disables lifecycle configuration"
},
{
"ParameterKey": "NoncurrentVersionExpirationInDays",
"ParameterValue": "Type: Number, Default: 30, Description: For buckets with versioning enabled (or suspended), specifies the time, in days, between when a new version of the object is uploaded to the bucket and when old versions of the object expire. When object versions expire, Amazon S3 permanently deletes them. If you specify a transition and expiration time, the expiration time must be later than the transition time."
},
{
"ParameterKey": "SubnetIDs",
"ParameterValue": "Type: List, Description: Subnet IDs"
},
{
"ParameterKey": "VersioningConfigurationStatus",
"ParameterValue": "Type: String, Default: Enabled, AllowedValues: [Enabled Suspended], Description: Whether or not to enable versioning on this bucket"
}
]
```
Read in yaml and output yaml:
$ cf_parameter_generator -f test.yaml -inyaml -outyaml
```yaml
- parameterkey: AWSAccount
parametervalue: 'Type: String'
- parameterkey: AmazonEC2FullAccessARN
parametervalue: 'Type: String'
- parameterkey: AmazonRoute53FullAccessARN
parametervalue: 'Type: String'
- parameterkey: AppTierFleetSize
parametervalue: 'Type: Number'
- parameterkey: AppTierInstanceType
parametervalue: 'Type: String'
```
Verbose yaml:
$ cf_parameter_generator -f test.yaml -inyaml -outyaml -v
```yaml
- parameterkey: AWSAccount
parametervalue: 'Type: String, Default: admints-dev, AllowedValues: [admints-dev
admints], Description: Name of the AWS Account'
- parameterkey: AmazonEC2FullAccessARN
parametervalue: 'Type: String, Default: arn:aws:iam::aws:policy/AmazonEC2FullAccess,
Description: The ARN of a policy granting ''full access'' rights to EC2'
- parameterkey: AmazonRoute53FullAccessARN
parametervalue: 'Type: String, Default: arn:aws:iam::aws:policy/AmazonRoute53FullAccess,
Description: The ARN of a policy granting ''full access'' rights to Route53'
- parameterkey: AppTierFleetSize
parametervalue: 'Type: Number, Default: 3, AllowedValues: [3], Description: App
Tier Fleet Size'
- parameterkey: AppTierInstanceType
parametervalue: 'Type: String, Default: m4.large, AllowedValues: [t2.medium t2.large
m4.large m4.xlarge m4.2xlarge m4.4xlarge m4.8xlarge], Description: App tier instance
type. NOTE: use t2.medium for stack testing only.'
```
Read in json and output yaml:
$ cf_parameter_generator -f test.json -outyaml
```yaml
- parameterkey: AccessControl
parametervalue: 'Type: String'
- parameterkey: ApplicationName
parametervalue: 'Type: String'
- parameterkey: AssetID
parametervalue: 'Type: String'
- parameterkey: Environment
parametervalue: 'Type: String'
- parameterkey: InstanceIDs
parametervalue: 'Type: List'
- parameterkey: LifecycleConfigurationStatus
parametervalue: 'Type: String'
- parameterkey: NoncurrentVersionExpirationInDays
parametervalue: 'Type: Number'
- parameterkey: SubnetIDs
parametervalue: 'Type: List'
- parameterkey: VersioningConfigurationStatus
parametervalue: 'Type: String'
```
Read in yaml and output json:
$ cf_parameter_generator -inyaml -f test.yaml
```json
[
{
"ParameterKey": "AWSAccount",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "AmazonEC2FullAccessARN",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "AmazonRoute53FullAccessARN",
"ParameterValue": "Type: String"
},
{
"ParameterKey": "AppTierFleetSize",
"ParameterValue": "Type: Number"
},
{
"ParameterKey": "AppTierInstanceType",
"ParameterValue": "Type: String"
}
]
```