Core Concepts
Components

CloudFormation

12min

CloudFormation (CFN) components in Microtica provide a robust framework for managing and deploying AWS infrastructure. These components are tightly integrated into the Microtica platform, allowing for seamless automation of infrastructure deployment. Below, you'll find a detailed explanation of each key file involved in a typical CFN component setup.

File structure

CloudFormation component structure
CloudFormation component structure
ο»Ώ

index.json

The index.json file is the core of your CloudFormation component. It defines the AWS resources that will be created or managed using CloudFormation.

index.json
ο»Ώ
  • Parameters: Defines user-configurable input parameters for the CloudFormation template. In this example, the BucketName parameter allows users to specify the name of the S3 bucket.
  • Resources: The section where AWS resources are defined.
  • Outputs: Specifies the outputs of the template. After deployment, the name of the S3 bucket is returned.

microtica.yaml

The microtica.yaml file outlines the CI/CD pipeline steps that Microtica will execute during the deployment process.

microtica.yaml
ο»Ώ

index.js

The index.js file is the entry point for managing the lifecycle of the component within Microtica. It uses the Microtica SDK to interact with CloudFormation.

index.js
ο»Ώ

schema.json

The schema.json file defines the schema for the component, specifying input parameters and ensuring that they conform to the expected structure and types. The input parameters defined in the schema will be visible in the Microtica Console, allowing users to easily configure the component during deployment.

JSON
ο»Ώ

All the files mentioned above should be placed within the .microtica folder at the root of your Git repository.

component.yaml

The component.yaml file is a specification file for a Microtica CloudFormation component. It provides metadata and configuration details about the component, including its name, description, and paths to the necessary CloudFormation and schema files.

component.yaml
ο»Ώ

For a full example, checkout our complete template.

ο»Ώ

This setup ensures that your CloudFormation component is well-organized, easy to manage, and ready for deployment through Microtica, providing a streamlined way to automate infrastructure management on AWS.

Custom input parameters

When working with CloudFormation components in Microtica, you may find the need to add custom input parameters to your templates. These parameters can help make your components more flexible and configurable.

Step 1: Update the JSON Schema (schema.json)

First, you need to define the new AccessControl parameter in the schema.json file. This will ensure that the parameter is visible and configurable in the Microtica Console.

Here is how you can update the schema.json file:

JSON
ο»Ώ

In this update:

  • The AccessControl parameter is added under properties with the description and two allowed values (enum): "Private" and "PublicRead".
  • The parameter is also included in the required array to ensure it must be provided during deployment.

Step 2: Update the CloudFormation Template (index.json)

Next, you need to update the index.json file to include the new AccessControl parameter in the CloudFormation template. This parameter will be used to set the appropriate access control policy on the S3 bucket.

Here’s the updated index.json file:

JSON
ο»Ώ

In this update:

  • The AccessControl parameter is added under Parameters, with allowed values "Private" and "PublicRead". The default value is set to "Private".
  • The AccessControl property is referenced in the S3Bucket resource definition, linking it to the corresponding parameter value provided during deployment.

ο»Ώ