MicroticaMicrotica

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.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 AccessControl parameter is added under properties, with a description and two allowed values (enum): "Private" and "PublicRead".
  • The parameter is also added to the required array, 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:

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 AccessControl parameter is added under Parameters, with allowed values "Private" and "PublicRead" and a default of "Private".
  • The AccessControl property is referenced in the S3Bucket resource definition, linking it to the value provided during deployment.

Next steps

On this page