Custom input parameters
Add custom input parameters to a Microtica CloudFormation component by updating the schema.json and index.json files, shown with an S3 example.
To make your CloudFormation templates more flexible and configurable, you can add custom input parameters. This example adds an AccessControl parameter to an S3 bucket component.
Step 1: Update the JSON schema (schema.json)
First, define the new AccessControl parameter in schema.json. This makes the parameter visible and configurable in the Microtica Console.
Here's how to update schema.json:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "schema://microtica/component-aws-s3.json",
"title": "Component Schema",
"type": "object",
"properties": {
"inputs": {
"type": "object",
"properties": {
"BucketName": {
"type": "string",
"description": "The name of the bucket."
},
"AccessControl": {
"type": "string",
"description": "The access control setting for the S3 bucket.",
"enum": ["Private", "PublicRead"]
}
},
"required": [
"BucketName",
"AccessControl"
],
"additionalProperties": false
}
},
"additionalProperties": false
}In this update:
- The
AccessControlparameter is added underproperties, with a description and two allowed values (enum): "Private" and "PublicRead". - The parameter is also added to the
requiredarray, so it must be provided during deployment.
Step 2: Update the CloudFormation template (index.json)
Next, update index.json to include the new AccessControl parameter in the CloudFormation template. This parameter sets the access control policy on the S3 bucket.
Here's the updated index.json:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS S3 Bucket custom component",
"Parameters": {
"BucketName": {
"Type": "String",
"Default": "",
"Description": "The name of the S3 bucket"
},
"AccessControl": {
"Type": "String",
"Description": "The access control setting for the S3 bucket.",
"AllowedValues": ["Private", "PublicRead"],
"Default": "Private"
}
},
"Resources": {
"S3Bucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketName": {
"Ref": "BucketName"
},
"AccessControl": {
"Ref": "AccessControl"
}
}
}
},
"Outputs": {
"BucketName": {
"Value": {
"Ref": "S3Bucket"
},
"Description": "Name of the S3 bucket"
}
}
}In this update:
- The
AccessControlparameter is added underParameters, with allowed values "Private" and "PublicRead" and a default of "Private". - The
AccessControlproperty is referenced in theS3Bucketresource definition, linking it to the value provided during deployment.
Next steps
CloudFormation
Define AWS infrastructure in Microtica with CloudFormation components, using index.json, microtica.yaml, index.js, schema.json, and component.yaml.
Terraform
Define cloud-agnostic infrastructure in Microtica with Terraform components, using the microtica.yaml, main.tf, outputs.tf, and variables.tf files.