CloudFormation configuration

Within the Attini framework you have 2 options to configure your CloudFormation stacks, Inline Parameters and Configuration File.

The Attini framework also automatically populate some parameters, see more at: Framework Parameters.

Inline parameters

Inline parameters are configured in the AttiniCfn Parameters section. These parameters have the highest priority and will therefore override parameters set in the Configuration File

Example

Type: AttiniCfn
Properties:
  Template: /path/to/my/template.yaml
  StackName: my-stack
  ConfigFile: /path/to/my/config.json
  Parameters:
    MyParameter: MyValue
    MyDbURL: dscsdcscsd.ndckjsndc.us-east-1.rds.amazonaws.com
  RoleArn: arn:aws:iam:my:role:arn

Configuration file

The configuration is a json or yaml file containing configuration for your CloudFormation stack.

Json

{
    "extends": "String",
    "stackName": "String",
    "templatePath": "String",
    "region": "String",
    "executionRole": "String",
    "stackRoleArn": "String",
    "outputPath": "String",
    "parameters": {
        "ParameterKey": "ParameterValue"
    },
    "tags": {
        "Key": "Value"
    }
}

Yaml

extends: String
stackName: String
templatePath: String
region: String
executionRole: String
stackRoleArn: String
outputPath: String
parameters:
  ParameterKey: ParameterValue
  Key: Value
tags:
  Key: Value

Please see AttiniCfn for parameter specific documentation.

extends

The extends configuration have to be the path to an other configuration file in the distribution. Attini will merge any configuration in that file into your current configuration. The configuration file that is referenced under extends will have a lower priority then the configuration in the current configuration file.

This is similar to how inheritance work in most object orientated programing languages.

Example

These files could be uses to configure a CloudFormation template containing a AWS::Lambda::Function

/config/default.json

Json

{
  "parameters": {
    "Runtime": "python3.7",
    "MemorySize": "256"
  }
}

/config/app.json

{
  "extends": "/config/default.json",
  "parameters": {
    "MemorySize": "512"
  },
  "tags": {
    "Version": "1.0.0"
  }
}

Now the configuration in /config/app.json that will look like this:

{
  "extends": "/config/default.json",
  "parameters": {
    "Runtime": "python3.7",
    "MemorySize": "512"
  },
  "tags": {
    "Version": "1.0.0"
  }
}

Yaml

parameters:
  Runtime: python3.7
  MemorySize: '256'

/config/app.json

extends: "/config/default.json"
parameters:
  MemorySize: '512'
tags:
  Version: 1.0.0

Now the configuration in /config/app.json that will look like this:

extends: "/config/default.json"
parameters:
  Runtime: python3.7
  MemorySize: '512'
tags:
  Version: 1.0.0

ParameterValue

The ParameterValue can either be String. Integer, Boolean (CloudFormation turns everything into a string anyway) or Object.

If its a String. Integer or a Boolean it will simply be applied as a CloudFormation parameter.

You can use an Object structure if you want to use Attini additional parameter configuration, like fallback.

fallback

Json

{
  "ParameterKey": {
    "fallback" : "boolean",
    "value": "Value"
  }
}

Yaml

ParameterKey:
  fallback: boolean
  value: Value

When fallback is true, the current configuration will always be honored by the Attini Framework. This means that the value will only have relevance when a parameter is set for the first time, either when creating the stack or adding a parameter to an exiting stack. This is useful if you have people in your organization that should be able to update some parameters straight in the console or via the AWS CLI. If for example you have a DBA that should be able to update the “AllocatedStorage” parameter on an stack containing a RDS instance manually, but the rest of the configuration should be managed by the Attini framework the config file could look something like:

Example

Json

{
  "parameters": {
    "Engine": "postgres",
    "AllocatedStorage": {
      "fallback" : true,
      "value": "500"
    }
  }
}

Yaml

parameters:
  Engine: postgres
  AllocatedStorage:
    fallback: true
    value: '500'

Framework parameters

If your Template have the following parameters, the Attini Framework will automatically populate it at runtime:

  • AttiniEnvironmentName (Can be configured in the attini-setup)

  • AttiniDistributionName

  • AttiniDistributionId

  • AttiniRandomString

AttiniEnvironmentName

Your current environment. This name can be “Re-mapped” by configuring the “EnvironmentParameterName” parameter in the attini-setup

AttiniDistributionName

The Deployments plans distribution name.

AttiniDistributionId

The Deployments plans current Id.

AttiniRandomString

A random UUID

This can be useful to trigger CloudFormation custom Resources

Example

The parameters in this stack will be automatically configured by the Attini framework:

AWSTemplateFormatVersion: "2010-09-09"

Parameters:
  AttiniEnvironmentName:
    Type: String

  AttiniDistributionName:
    Type: String

  AttiniDistributionId:
    Type: String

  AttiniRandomString:
    Type: String

Resources:
  ...