Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Terraform module which creates name format for AWS resources

License

NotificationsYou must be signed in to change notification settings

cawcaw253/terraform-aws-namer

Repository files navigation

Terraform module which creates name format for AWS resources

SWUbanner

This module is to help you create resources in AWS using Terrafom to create names according to the rules.Please refer toExamples for examples of usage.In the following, I will explain the usage and structure in a simple way.

Usage

module"namer" {source="../../"prefix=["namer","prod"]}module"namer_with_additional_identifier_verb" {source="../../"with_additional_identifier_verb=trueprefix=["namer","prod"]}..."Name" =format(module.namer.subnet,"bastion","pub", each.key)..."Name" =format(module.namer_with_additional_identifier_verb.ec2_instance,"rest","auth")

Outputs

The overall output should look something like this

# delimiter = "-"# Default${resource_name}-${prefix}-${identifier}# With Optional Resource Number# with_additional_identifier_verb = true${resource_name}-${prefix}-${identifier}-${additional_identifier}

We'll discuss each element in more detail below.

resource_name

This element is the name of the resource provided by AWS.

This module uses abbreviated resource names, which can be found and changed in [local.tf] (./local.tf).

prefix

This element is a user-definable prefix value and can provide multiple values in an array.

# delimiter = "-"# ["poc", "dev"]prefix="poc-dev"# ["terraform", "prod"]prefix="terraform-prod"

identifier

This element is an identifier, with one or two arguments.

ex)${service_name},${subnet_name}-${route_type}

You can see how many arguments it has in [outputs.tf] (./outputs.tf).

additional_identifier (optional)

This is an optionally available element, enabled by adding thewith_additional_identifier_verb = true option.

This is an identifier to use when you need to create multiple resources with the same name.If this is not the case, we recommend not using it.

Below shows the result of adding this option when getting the name of an ec2_instance.

# delimiter = "-"# prefix = ["terraform", "qa"]# identifier = ["rest"]# region = "ap-northeast-2"# with_additional_identifier_verb = true-> ec2-terraform-qa-rest-an2-%s

For more usage examples, seeexamples/complete/.

Examples

Terraform Docs

Providers

NameVersion
awsn/a

Modules

No modules.

Resources

NameType
aws_availability_zones.available_zonesdata source
aws_region.currentdata source

Inputs

NameDescriptionTypeDefaultRequired
delimiterA delimiter variable that combines each element.string"-"no
identifierA identifier value of the form{resource_name} {prefix} {identifier} {sufix}, where the listed values are combined into adelimiter variable.list(string)[]no
prefixA prefix value of the form{resource_name} {prefix} {identifier} {sufix}, where the listed values are combined into adelimiter variable.list(string)
[
"project",
"environment"
]
no
with_additional_identifier_verbIf this value is false, naming doesn't contain additional identifier suffix.boolfalseno
with_random_stringn/aboolfalseno
with_resource_number_verbIf this value is false, naming doesn't contain number suffix.boolfalseno

Outputs

NameDescription
application_load_balancerApplication Load Balancer
classic_load_balancerClassic Load Balancer
ec2_instanceEC2 Instance
eks_clusterEKS Cluster
eks_node_groupEKS Node Group
elastic_ipElastic IP Address

Example :
setting :
region = ap-northeast-2
delimiter = "-"
prefix = ["project", "env"]
with_resource_number_verb = false // if true, please check examples/with-resource-number-verb
result :
eip-project-env-an2%s-%s
usage :
format(module.namer.elastic_ip, "az_value", "identifier")
elastic_load_balancerElastic Load Balancer
elasticacheElasticache
elasticache_replication_groupElasticache Replication Group
elasticache_subnet_groupElasticache Subnet Group
iam_policyIAM Policy
iam_roleIAM Role
internet_gatewayInternet Gateway

Example :
setting :
region = ap-northeast-2
delimiter = "-"
prefix = ["project", "env"]
with_resource_number_verb = false // if true, please check examples/with-resource-number-verb
result :
igw-project-env-an2
usage :
module.namer.internet_gateway
key_management_serviceKey Management Service
kinesis_data_streamKinesis Data Stream
nat_gatewayNAT Gateway

Example :
setting :
region = ap-northeast-2
delimiter = "-"
prefix = ["project", "env"]
with_resource_number_verb = false // if true, please check examples/with-resource-number-verb
result :
nat-project-env-an2%s
usage :
format(module.namer.nat_gateway, "az_value")
network_access_control_listNetwork Access Control List
network_load_balancerNetwork Load Balancer
rds_clusterRDS Cluster
rds_instanceRDS Instance
rds_parameter_groupRDS Parameter Group
rds_subnet_groupRDS Subnet Group
route_tableRoute Table

Example :
setting :
region = ap-northeast-2
delimiter = "-"
prefix = ["project", "env"]
with_resource_number_verb = false // if true, please check examples/with-resource-number-verb
result :
rt-project-env-%s-%s-an2%s
usage :
format(module.namer.route_table, "identifier", "subnet_type [pri, pub]", "az_value")
secrets_managerSecrets Manager
security_groupSecurity Group
simple_email_serviceSimple Email Service
simple_queue_serviceSimple Queue Service
subnetSubnet

Example :
setting :
region = ap-northeast-2
delimiter = "-"
prefix = ["project", "env"]
with_resource_number_verb = false // if true, please check examples/with-resource-number-verb
result :
snet-project-env-%s-%s-an2%s
usage :
format(module.namer.subnet, "identifier", "subnet_type [pri, pub]", "az_value")
target_groupTarget Group
transit_gatewayTransit Gateway
transit_gateway_attachmentTransit Gateway Attachment
transit_gateway_route_tableTransit Gateway Route Table
virtual_private_cloudVirtual Private Cloud

Example :
setting :
region = ap-northeast-2
delimiter = "-"
prefix = ["project", "env"]
with_resource_number_verb = false // if true, please check examples/with-resource-number-verb
result :
vpc-project-env-an2
usage :
module.namer.virtual_private_cloud

About

Terraform module which creates name format for AWS resources

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp