CloudFormation
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.
The index.json file is the core of your CloudFormation component. It defines the AWS resources that will be created or managed using CloudFormation.
- 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.
The microtica.yaml file outlines the CI/CD pipeline steps that Microtica will execute during the deployment process.
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.
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.
All the files mentioned above should be placed within the .microtica folder at the root of your Git repository.
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.
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.
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.
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:
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.
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:
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.
ο»Ώ