Skip to content

justtrackio/terraform-aws-ocean-ecs

terraform-aws-ocean-ecs

Terraform module which creates an spotinst ocean ecs cluster

Requirements

Name Version
terraform >= 1.3.0
aws >= 5.52.0
spotinst >= 1.175.0
tls >= 4.0.5

Providers

Name Version
aws >= 5.52.0
aws.owner >= 5.52.0
spotinst >= 1.175.0
tls >= 4.0.5

Modules

Name Source Version
sg cloudposse/security-group/aws 1.0.1
this justtrackio/label/null 0.26.0

Resources

Name Type
aws_ecs_cluster.default resource
aws_iam_instance_profile.default resource
aws_iam_role.default resource
aws_iam_role_policy_attachment.amazon_ec2_container_registry_read_only resource
aws_iam_role_policy_attachment.amazon_ec2_container_service_for_ec2_role resource
aws_iam_role_policy_attachment.amazon_ssm_managed_instance_core resource
aws_key_pair.ecs resource
aws_route53_vpc_association_authorization.auth resource
aws_route53_zone_association.assoc resource
aws_service_discovery_private_dns_namespace.main resource
spotinst_ocean_ecs.default resource
tls_private_key.ecs resource
aws_iam_policy_document.assume_role data source
aws_route53_zone.service_discovery data source
aws_ssm_parameter.image_id data source

Inputs

Name Description Type Default Required
additional_tag_map Additional key-value pairs to add to each map in tags_as_list_of_maps. Not added to tags or id.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration.
map(string) {} no
attributes ID element. Additional attributes (e.g. workers or cluster) to add to id,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the delimiter
and treated as a single ID element.
list(string) [] no
autoscaler_auto_headroom_percentage The auto-headroom percentage. Set a number between 0-200 to control the headroom % of the cluster. Relevant when isAutoConfig=true number 10 no
autoscaler_headroom_cpu_per_unit Optionally configure the number of CPUs to allocate the headroom. CPUs are denoted in millicores, where 1000 millicores = 1 vCPU number null no
autoscaler_headroom_memory_per_unit Optionally configure the amount of memory (MB) to allocate the headroom number null no
autoscaler_headroom_num_of_units The number of units to retain as headroom, where each unit has the defined headroom CPU and memory number null no
aws_account_id AWS account id string null no
aws_region AWS region string null no
context Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as null to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
any
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
no
create_key_pair Whether to create the key pair to attach the instances string true no
delimiter Delimiter to be used between ID elements.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
string null no
descriptor_formats Describe additional descriptors to be output in the descriptors output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
{<br> format = string<br> labels = list(string)<br>}
(Type is any so the map values can later be enhanced to provide additional options.)
format is a Terraform format string to be passed to the format() function.
labels is a list of labels, in order, to pass to format() function.
Label values will be normalized before being passed to format() so they will be
identical to how they appear in id.
Default is {} (descriptors output will be empty).
any {} no
ecs_allow_privileged_containers Whether or not to allow privileged containers, defaults to true bool true no
ecs_enable_spot_instance_draining Whether or not to enable spot instance draining, defaults to true bool true no
enabled Set to false to prevent the module from creating any resources bool null no
environment ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' string null no
id_length_limit Limit id to this many characters (minimum 6).
Set to 0 for unlimited length.
Set to null for keep the existing setting, which defaults to 0.
Does not affect id_full.
number null no
initial_vpc_id The VPC ID used for service discovery namespace creation when you are not the owner if var.vpc_id. You can later on authorize the vpc to hosted zone association and tell the vpc owner to assign your hosted zone to the vpc. string null no
key_pair The key pair to attach the instances string "ecs" no
label_key_case Controls the letter case of the tags keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the tags input.
Possible values: lower, title, upper.
Default value: title.
string null no
label_order The order in which the labels (ID elements) appear in the id.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.
list(string) null no
label_value_case Controls the letter case of ID elements (labels) as included in id,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the tags input.
Possible values: lower, title, upper and none (no transformation).
Set this to title and set delimiter to "" to yield Pascal Case IDs.
Default value: lower.
string null no
labels_as_tags Set of labels (ID elements) to include as tags in the tags output.
Default is to include all labels.
Tags with empty values will not be included in the tags output.
Set to [] to suppress all generated tags.
Notes:
The value of the name tag, if included, will be the id, not the name.
Unlike other null-label inputs, the initial setting of labels_as_tags cannot be
changed in later chained modules. Attempts to change it will be silently ignored.
set(string)
[
"default"
]
no
max_size The upper limit of instances the cluster can scale up to number null no
metrics_send_metrics Whether or not send anonymous metrics bool false no
min_size The lower limit of instances the cluster can scale down to number 1 no
name ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a tag.
The "name" tag is set to the full id string. There is no tag with the value of the name input.
string null no
namespace ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique string null no
ocean_image_id_ssm_parameter SSM Parameter name which contains the AMI ID, defaults to official latest bottlerocket ami string "/aws/service/bottlerocket/aws-ecs-1/x86_64/latest/image_id" no
ocean_update_policy_should_roll Whether or not a change to the ocean should roll the cluster bool true no
organizational_unit Usually used to indicate the AWS organizational unit, e.g. 'prod', 'sdlc' string null no
regex_replace_chars Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.
string null no
service_discovery_private_dns_name The name of the namespace string null no
stage ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' string null no
subnet_ids A comma-separated list of subnet identifiers for the Ocean cluster. Subnet IDs should be configured with auto assign public ip list(string) [] no
tags Additional tags (e.g. {'BusinessUnit': 'XYZ'}).
Neither the tag keys nor the tag values will be modified by this module.
map(string) {} no
tenant ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for string null no
vpc_id The VPC ID string null no
whitelist Instance types allowed in the Ocean cluster, Cannot be configured if blacklist is configured list(string)
[
"c4.large",
"c4.xlarge",
"c4.2xlarge",
"c4.4xlarge",
"c5.large",
"c5.xlarge",
"c5.2xlarge",
"c5.4xlarge",
"c5a.large",
"c5a.xlarge",
"c5a.2xlarge",
"c5a.4xlarge",
"c5ad.large",
"c5ad.xlarge",
"c5ad.2xlarge",
"c5ad.4xlarge",
"c5d.large",
"c5d.xlarge",
"c5d.2xlarge",
"c5d.4xlarge",
"c5n.large",
"c5n.xlarge",
"c5n.2xlarge",
"c5n.4xlarge",
"c6a.large",
"c6i.large",
"c6a.xlarge",
"c6i.xlarge",
"c6a.2xlarge",
"c6i.2xlarge",
"c6a.4xlarge",
"c6i.4xlarge",
"g4dn.xlarge",
"g4dn.2xlarge",
"i3.large",
"i3.xlarge",
"i3en.large",
"i3en.xlarge",
"i4i.large",
"i4i.xlarge",
"inf1.xlarge",
"inf1.2xlarge",
"m4.large",
"m4.xlarge",
"m4.2xlarge",
"m5.large",
"m5.xlarge",
"m5.2xlarge",
"m5a.large",
"m5a.xlarge",
"m5a.2xlarge",
"m5ad.large",
"m5ad.xlarge",
"m5ad.2xlarge",
"m5d.large",
"m5d.xlarge",
"m5d.2xlarge",
"m5dn.large",
"m5dn.xlarge",
"m5dn.2xlarge",
"m5n.large",
"m5n.xlarge",
"m5n.2xlarge",
"m6i.large",
"m6i.xlarge",
"m6i.2xlarge",
"m6a.large",
"m6a.xlarge",
"m6a.2xlarge",
"r4.large",
"r4.xlarge",
"r5.large",
"r5.xlarge",
"r5a.large",
"r5a.xlarge",
"r5ad.large",
"r5ad.xlarge",
"r5b.large",
"r5b.xlarge",
"r5d.large",
"r5d.xlarge",
"r5dn.large",
"r5dn.xlarge",
"r5n.large",
"r5n.xlarge",
"r6i.large",
"r6i.xlarge",
"r6a.large",
"r6a.xlarge",
"z1d.large",
"z1d.xlarge"
]
no

Outputs

Name Description
ecs_cluster_arn Arn of the ecs cluster
ecs_cluster_id Id of the ecs cluster
ecs_cluster_name Name of the ecs cluster
key_pair_private_key private key for allowing to connect to the amazon linux 2 instances
key_pair_public_key public key used on the amazon linux 2 instances
service_discovery_dns_namespace_hosted_zone_id Hosted zone id of the discovery namespace
service_discovery_dns_namespace_id ID of the discovery namespace