Under the hood, ufo creates most of the required resources with a CloudFormation stack. This includes the ELB, Target Group, Listener, Security Groups, ECS Service, and Route 53 records. You might need to customize these resources. Here are the ways to customize the resources that ufo creates.
- Settings - This is done with the
.ufo/settings/cfn/default.ymlfile. This is the main and recommended way to customize.
- Override cfn template - You can specify your own template to use. You save this template at
.ufo/settings/cfn/stack.yml. Use this approach as a last resort only when necessary.
The recommended approach to customize the CloudFormation resources is by adding properties to
The properties in the file
.ufo/settings/cfn/default.yml map directly to ufo’s CloudFormation resources. It allows you to customize the resources. The keys get transform to CamelCase keys to work with the CloudFormation template.
Example of Customization
Let’s customize the
AWS::ElasticLoadBalancingV2::TargetGroup resource created by CloudFormation. We’ll adjust the
8. Here’s the relevant section of the
TargetGroup: ... TargetGroupAttributes: - Key: deregistration_delay.timeout_seconds Value: 8
The value will be injected to the generated CloudFormation template under the corresponding “TargetGroup Properties”. The generated template looks something like this:
TargetGroup: Properties: ... TargetGroupAttributes: - Key: deregistration_delay.timeout_seconds Value: 8 ...
In this way, you can customize and override any properties associated with resources created by the ufo CloudFormation stack.
Here’s a list of the resources in the cfn/stack.yml that you can customize:
base.yml profile files always get evaluated and env-specific ENV.yml file are layered or merged together. This miminizes duplication. For example, these files are merged:
The settings in
development.yml override the settings in
base.yml. Here’s another example:
Note, this feature is available in v5.0.5+.
For the most up to date list check out the cfn/stack.yml source code directly.
Override Cfn Template
You can override the source template that ufo uses by creating your own and saving it at
.ufo/settings/cfn/stack.yml in your project. It is recommended that you copy the source code and work from there cfn/stack.yml. Use this approach as a last resort only when absolutely necessary as it’ll likely break with a future version of ufo.
CloudFormation Stack Name
The CloudFormation stack name is based on the service name, UFO_ENV and UFO_ENV_EXTRA. A few examples help demonstrate:
|ufo ship demo-web||demo-web-development|
|ufo ship demo-web --cluster dev||demo-web-development|
|UFO_ENV_EXTRA=2 ufo ship demo-web --cluster dev||demo-web-development-2|
CloudFormation Stack Source Code
The CloudFormation stack is currently generated from a template. The source code for this template is located at cfn/stack.yml. This implementation might change in the future.
Pro tip: Use the <- and -> arrow keys to move back and forward.