ipam
This component is responsible for provisioning IPAM per region in a centralized account.
Usage
Stack Level: Regional
This component wraps the cloudposse/terraform-aws-ipam
module, which takes IPAM pools as a flat pools map keyed by your own name
for each pool. Hierarchy is expressed by a pool naming another entry as its
parent (rather than the old nested pool_configurations / sub_pools). Pool
nesting is capped at a depth of 4.
Provisioned CIDRs go under a pool's cidrs, manual reservations under
allocations, and RAM sharing under ram_share. As a convenience, an entry in
ram_share.principals that matches an account-map account name is resolved to
that account's ID; literal account IDs and ARNs pass through, and the current
account is dropped (RAM cannot share a resource with its own owner).
Here's an example snippet for how to use this component.
components:
terraform:
ipam:
vars:
enabled: true
pools:
core:
cidrs:
primary:
cidr: 10.96.0.0/12
core-network:
parent: core
locale: us-east-2
cidrs:
primary:
cidr: 10.96.0.0/16
ram_share:
principals: [core-network]
core-auto:
parent: core
locale: us-east-2
cidrs:
primary:
cidr: 10.97.0.0/16
ram_share:
principals: [core-auto]
plat:
cidrs:
primary:
cidr: 10.112.0.0/12
plat-dev:
parent: plat
locale: us-east-2
cidrs:
primary:
cidr: 10.112.0.0/16
ram_share:
principals: [plat-dev]
plat-prod:
parent: plat
locale: us-east-2
cidrs:
primary:
cidr: 10.114.0.0/16
ram_share:
principals: [plat-prod]
Variables
Required Variables
region(string) requiredAWS Region
Optional Variables
account_map_environment_name(string) optionalThe name of the environment where
account_mapis provisionedDefault value:
"gbl"account_map_stage_name(string) optionalThe name of the stage where
account_mapis provisionedDefault value:
"root"account_map_tenant_name(string) optionalThe name of the tenant where
account_mapis provisioned.If the
tenantlabel is not used, leave this asnull.Default value:
nullcreate_ipam(bool) optionalWhether to create an
aws_vpc_ipam. Set tofalseto build pools inside an
IPAM that already exists (for a second instance of this component in another
Region, supplyexisting_ipam_idandexisting_ipam_scope_id).Default value:
truecreate_resource_discovery(bool) optionalWhether to create an
aws_vpc_ipam_resource_discovery. Only needed for cross-account or cross-organization monitoring.Default value:
falsedelegated_admin_account(string) optionalAccount to delegate IPAM administration to, as either an
account-mapaccount name (resolved to its ID) or a literal 12-digit account ID. Required whenorganization_admin_enabledistrue.Default value:
nullexisting_ipam_id(string) optionalID of an existing
aws_vpc_ipamto build against. Only consulted whencreate_ipamisfalse.Default value:
nullexisting_ipam_scope_id(string) optionalID of an existing IPAM scope that top-level pools default into. Required when
create_ipamisfalseand a top-level pool does not resolve a scope of its own.Default value:
nullipam_cascade_enabled(bool) optionalWhether to enable cascade delete on the IPAM. Delete-time only; on destroy it tears down every private scope, pool, and allocation, including address space in live use.
Default value:
falseipam_description(string) optionalDescription for the IPAM. Defaults to the null-label ID. Only used when
create_ipamistrue.Default value:
nullipam_tier(string) optionalIPAM tier. Valid values:
free,advanced. Leaving thisnullinherits the provider default ofadvanced(the billable tier).Default value:
nullipam_timeoutsoptionalOperation timeouts for the
aws_vpc_ipamresource.nullentries inherit the provider defaults of 3m each.Type:
object({
create = optional(string, null)
update = optional(string, null)
delete = optional(string, null)
})Default value:
{ }metered_account(string) optionalWhich account is metered for IPAM usage. Valid values:
ipam-owner,resource-owner.nullnever produces a diff.Default value:
nulloperating_regions(list(string)) optionalRegions the IPAM may discover, monitor, and allocate from. Must include the Region the component is applied into at create time. When empty, the module registers just the current Region.
Default value:
[ ]organization_admin_enabled(bool) optionalWhether to delegate IPAM administration to
delegated_admin_accountvia theorganization-adminsubmodule. Enable only in a stack that targets the management account.Default value:
falsepool_cidr_timeoutsoptionalOperation timeouts applied to every
aws_vpc_ipam_pool_cidr.nullentries inherit the provider defaults of create 10m and delete 32m. Do not lower the 32m delete.Type:
object({
create = optional(string, null)
delete = optional(string, null)
})Default value:
{ }pool_timeoutsoptionalOperation timeouts applied to every
aws_vpc_ipam_pool.nullentries inherit the provider defaults (35m create).Type:
object({
create = optional(string, null)
update = optional(string, null)
delete = optional(string, null)
})Default value:
{ }poolsoptionalIPAM pools to create, as a flat map keyed by your own name for each pool.
Keys must be known atplantime. Hierarchy is expressed by naming another
entry as a pool'sparent; a pool with noparentis top-level. Nesting is
capped at a depth of 4. Each pool's provisioned CIDRs nest undercidrs, its
manual reservations underallocations, and its RAM sharing underram_share.Type:
map(object({
parent = optional(string, null)
address_family = optional(string, "ipv4")
locale = optional(string, null)
ipam_scope_id = optional(string, null)
scope = optional(string, null)
aws_service = optional(string, null)
public_ip_source = optional(string, null)
publicly_advertisable = optional(bool, null)
source_resource = optional(object({
resource_id = string
resource_owner = string
resource_region = string
resource_type = optional(string, "vpc")
}), null)
allocation_default_netmask_length = optional(number, null)
allocation_max_netmask_length = optional(number, null)
allocation_min_netmask_length = optional(number, null)
allocation_resource_tags = optional(map(string), {})
auto_import = optional(bool, null)
description = optional(string, null)
cascade = optional(bool, false)
tags = optional(map(string), {})
cidrs = optional(map(object({
cidr = optional(string, null)
netmask_length = optional(number, null)
cidr_authorization_context = optional(object({
message = optional(string, null)
signature = optional(string, null)
}), null)
})), {})
allocations = optional(map(object({
cidr = optional(string, null)
netmask_length = optional(number, null)
disallowed_cidrs = optional(set(string), null)
description = optional(string, null)
tags = optional(map(string), {})
})), {})
ram_share = optional(object({
principals = optional(set(string), [])
allow_external_principals = optional(bool, false)
permission_arns = optional(set(string), null)
tags = optional(map(string), {})
}), null)
}))Default value:
{ }private_gua_enabled(bool) optionalWhether IPAM treats your own globally-unique IPv6 ranges (from
2000::/3) as private address space. Maps to the provider'senable_private_gua.Default value:
nullram_share_permission_arns(list(string)) optionalDefault RAM permission ARNs applied to every pool share that does not set its own
permission_arns. Leave empty to let RAM apply its default managed permission for IPAM pools.Default value:
[ ]resource_discovery_associationsoptionalResource discoveries to associate with this IPAM, keyed by name. Keys must be known at
plantime.ipam_iddefaults to this component's IPAM.Type:
map(object({
ipam_id = optional(string, null)
ipam_resource_discovery_id = string
tags = optional(map(string), {})
}))Default value:
{ }resource_discovery_description(string) optionalDescription for the resource discovery. Defaults to the null-label ID. Only used when
create_resource_discoveryistrue.Default value:
nullresource_discovery_operating_regions(list(string)) optionalRegions the resource discovery monitors. When empty, falls back to
operating_regions, and then to the current Region. Must include the current Region at create time.Default value:
[ ]resource_discovery_organizational_unit_exclusions(list(string)) optionalAWS Organizations entity paths to exclude from discovery — Organizations IDs joined by
/. End a path with/*to exclude all child OUs.Default value:
[ ]scopesoptionalAdditional private IPAM scopes to create, keyed by name. Keys must be known
atplantime. Public scopes cannot be created; consume the single public
scope read-only through thepublic_default_scope_idoutput.Type:
map(object({
description = optional(string, null)
tags = optional(map(string), {})
}))Default value:
{ }
Context Variables
The following variables are defined in the context.tf file of this module and part of the terraform-null-label pattern.
context.tf file of this module and part of the terraform-null-label pattern.additional_tag_map(map(string)) optionalAdditional key-value pairs to add to each map in
tags_as_list_of_maps. Not added totagsorid.
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.Required: No
Default value:
{ }attributes(list(string)) optionalID element. Additional attributes (e.g.
workersorcluster) to add toid,
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 thedelimiter
and treated as a single ID element.Required: No
Default value:
[ ]context(any) optionalSingle object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables asnullto use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.Required: No
Default value:
{
"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
}delimiter(string) optionalDelimiter to be used between ID elements.
Defaults to-(hyphen). Set to""to use no delimiter at all.Required: No
Default value:
nulldescriptor_formats(any) optionalDescribe additional descriptors to be output in the
descriptorsoutput map.
Map of maps. Keys are names of descriptors. Values are maps of the form
\{<br/> format = string<br/> labels = list(string)<br/> \}
(Type isanyso the map values can later be enhanced to provide additional options.)
formatis a Terraform format string to be passed to theformat()function.
labelsis a list of labels, in order, to pass toformat()function.
Label values will be normalized before being passed toformat()so they will be
identical to how they appear inid.
Default is{}(descriptorsoutput will be empty).Required: No
Default value:
{ }enabled(bool) optionalSet to false to prevent the module from creating any resources
Required: NoDefault value:
nullenvironment(string) optionalID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'
Required: NoDefault value:
nullid_length_limit(number) optionalLimit
idto this many characters (minimum 6).
Set to0for unlimited length.
Set tonullfor keep the existing setting, which defaults to0.
Does not affectid_full.Required: No
Default value:
nulllabel_key_case(string) optionalControls the letter case of the
tagskeys (label names) for tags generated by this module.
Does not affect keys of tags passed in via thetagsinput.
Possible values:lower,title,upper.
Default value:title.Required: No
Default value:
nulllabel_order(list(string)) optionalThe 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.Required: No
Default value:
nulllabel_value_case(string) optionalControls 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 thetagsinput.
Possible values:lower,title,upperandnone(no transformation).
Set this totitleand setdelimiterto""to yield Pascal Case IDs.
Default value:lower.Required: No
Default value:
nulllabels_as_tags(set(string)) optionalSet of labels (ID elements) to include as tags in the
tagsoutput.
Default is to include all labels.
Tags with empty values will not be included in thetagsoutput.
Set to[]to suppress all generated tags.
Notes:
The value of thenametag, if included, will be theid, not thename.
Unlike othernull-labelinputs, the initial setting oflabels_as_tagscannot be
changed in later chained modules. Attempts to change it will be silently ignored.Required: No
Default value:
[
"default"
]name(string) optionalID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as atag.
The "name" tag is set to the fullidstring. There is no tag with the value of thenameinput.Required: No
Default value:
nullnamespace(string) optionalID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique
Required: NoDefault value:
nullregex_replace_chars(string) optionalTerraform 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.Required: No
Default value:
nullstage(string) optionalID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'
Required: NoDefault value:
nulltags(map(string)) optionalAdditional tags (e.g.
{'BusinessUnit': 'XYZ'}).
Neither the tag keys nor the tag values will be modified by this module.Required: No
Default value:
{ }tenant(string) optionalID element (Rarely used, not included by default). A customer identifier, indicating who this instance of a resource is for
Required: NoDefault value:
null
Outputs
allocation_cidrsMap from
<pool name>/<allocation name>to the CIDR reserved by each manual reservation.allocation_idsMap from
<pool name>/<allocation name>to the AWS allocation ID of each manual reservation.allocationsMap from
<pool name>/<allocation name>to the fullaws_vpc_ipam_pool_cidr_allocationresource (all attributes).default_resource_discovery_association_idID of the resource discovery association IPAM creates alongside itself.
default_resource_discovery_idID of the resource discovery IPAM creates alongside itself.
delegated_admin_account_idID of the account holding the IPAM delegation.
nullwhenorganization_admin_enabledisfalse.delegationThe full
aws_vpc_ipam_organization_admin_accountresource (all attributes).nullwhenorganization_admin_enabledisfalse.ipamThe full
aws_vpc_ipamresource created by the module (all attributes).nullwhencreate_ipamisfalse.ipam_arnARN of the IPAM created by this component.
nullwhencreate_ipamisfalse.ipam_idID of the IPAM — the one created here, or
existing_ipam_idwhencreate_ipamisfalse.pool_arnsMap from the keys of
poolsto the ARN of each created pool.pool_cidr_idsMap from
<pool name>/<cidr name>to the Terraform ID of each provisioned pool CIDR.pool_cidrsMap from the keys of
poolsto the list of CIDRs provisioned into that pool.pool_cidrs_detailMap from
<pool name>/<cidr name>to the fullaws_vpc_ipam_pool_cidrresource (all attributes).pool_configurationsThe effective
poolsmap passed to the module, after account-map RAM-principal resolution. Preserved under the old component's output name.pool_idsMap from the keys of
poolsto the ID of each created pool, flattened across every depth tier. The primary interface for downstream consumers.pool_namesMap from the keys of
poolsto the null-label ID generated for each pool.pool_scope_idsMap from the keys of
poolsto the scope each pool was created in.pool_statesMap from the keys of
poolsto the state of each created pool.poolsMap from the keys of
poolsto the fullaws_vpc_ipam_poolresource (all attributes).private_default_scope_idID of the IPAM's private default scope, which top-level pools land in unless they name another.
public_default_scope_idID of the IPAM's public default scope. Read-only.
nullwhencreate_ipamisfalse.ram_resource_share_arnsMap from the keys of
poolsthat requested RAM sharing to the ARN of that pool's resource share.ram_resource_sharesMap from the keys of
poolsthat requested RAM sharing to the fullaws_ram_resource_shareresource (all attributes).resource_discoveryThe full
aws_vpc_ipam_resource_discoveryresource created by the module.nullwhencreate_resource_discoveryisfalse.resource_discovery_arnARN of the resource discovery created by this component.
nullwhencreate_resource_discoveryisfalse.resource_discovery_association_idsMap from the keys of
resource_discovery_associationsto the ID of each association.resource_discovery_associationsMap from the keys of
resource_discovery_associationsto the fullaws_vpc_ipam_resource_discovery_associationresource (all attributes).resource_discovery_idID of the resource discovery created by this component.
nullwhencreate_resource_discoveryisfalse.scope_arnsMap from the keys of
scopesto the ARN of each created scope.scope_countNumber of scopes on the IPAM, including the two default ones.
scope_idsMap from the keys of
scopesto the ID of each created scope.scopesMap from the keys of
scopesto the fullaws_vpc_ipam_scoperesource (all attributes).
Dependencies
Requirements
terraform, version:>= 1.4.0aws, version:>= 6.56.0
Providers
aws, version:>= 6.56.0
Modules
| Name | Version | Source | Description |
|---|---|---|---|
account_map | 2.0.1 | cloudposse/stack-config/yaml//modules/remote-state | n/a |
iam_roles | latest | ../account-map/modules/iam-roles | n/a |
ipam | v0.1.0 | git::https://github.com/cloudposse/terraform-aws-ipam.git | Pinned to the v0.1.0 release tag via git: the module is not published on the Terraform Registry yet. Swap to source = "cloudposse/ipam/aws" + version = "0.1.0" once it is. |
ipam_organization_admin | v0.1.0 | git::https://github.com/cloudposse/terraform-aws-ipam.git//modules/organization-admin | Delegated IPAM administration is an organization-wide singleton that must run in the management account, and its destroy revokes the delegation for the entire organization. It is intentionally a separate submodule; enable it only in a stack that targets the management account. |
this | 0.25.0 | cloudposse/label/null | n/a |
Resources
The following resources are used by this module:
Data Sources
The following data sources are used by this module:
aws_caller_identity.current(data source)