All Projects → traveloka → terraform-aws-resource-naming

traveloka / terraform-aws-resource-naming

Licence: Apache-2.0 License
Terraform module to generate resource name with random_id added as suffix.

Programming Languages

HCL
1544 projects

Projects that are alternatives of or similar to terraform-aws-resource-naming

terraform-aws-waf-webacl-supporting-resources
A module to create several resources needed by AWS WAF WebACL.
Stars: ✭ 25 (+38.89%)
Mutual labels:  hcl, terraform-module
terraform-aws-autoscaling
A terraform module which provisions an auto scaling group along with its launch template
Stars: ✭ 32 (+77.78%)
Mutual labels:  hcl, terraform-module
terraform-linode-k8s
Kubernetes installer for Linode
Stars: ✭ 63 (+250%)
Mutual labels:  hcl, terraform-module
terraform-aws-kms
This terraform module creates a KMS Customer Master Key (CMK) and its alias.
Stars: ✭ 14 (-22.22%)
Mutual labels:  hcl, terraform-module
combinator
Combinator.ml's central repo, documentation and website
Stars: ✭ 24 (+33.33%)
Mutual labels:  terraform-module
terraform-aws-sqs
Terraform module which creates SQS resources on AWS 🇺🇦
Stars: ✭ 53 (+194.44%)
Mutual labels:  terraform-module
terraform-aws-elasticache-redis
A Terraform module to create an AWS Redis ElastiCache cluster.
Stars: ✭ 29 (+61.11%)
Mutual labels:  terraform-module
terraform-aws-apigateway-v2
Terraform module to create an AWS API Gateway v2 (HTTP/WebSocket) 🇺🇦
Stars: ✭ 71 (+294.44%)
Mutual labels:  terraform-module
terraform-aws-ecs-cloudwatch-sns-alarms
Terraform module to create CloudWatch Alarms on ECS Service level metrics.
Stars: ✭ 23 (+27.78%)
Mutual labels:  terraform-module
terraform-github-repository-webhooks
Terraform module to provision webhooks on a set of GitHub repositories
Stars: ✭ 20 (+11.11%)
Mutual labels:  terraform-module
rust-hcl
A Rust library for working with the HashiCorp Configuration Language (HCL).
Stars: ✭ 14 (-22.22%)
Mutual labels:  hcl
provose
Provose is a new way to manage your Amazon Web Services infrastructure.
Stars: ✭ 27 (+50%)
Mutual labels:  terraform-module
terraform-aws-account
🌳 A sustainable Terraform Package which creates Account & IAM resources on AWS
Stars: ✭ 18 (+0%)
Mutual labels:  terraform-module
terraform-vultr-condor
Kubernetes Deployment Tool for Vultr
Stars: ✭ 60 (+233.33%)
Mutual labels:  terraform-module
refmt
Reformat HCL ⇄ JSON ⇄ YAML.
Stars: ✭ 19 (+5.56%)
Mutual labels:  hcl
terraform-vsphere-single-vm
Deploy single vSphere VM with Terraform - template.
Stars: ✭ 21 (+16.67%)
Mutual labels:  hcl
hcl-to-json
HCL to JSON converter in CoffeeScript
Stars: ✭ 15 (-16.67%)
Mutual labels:  hcl
terraform-aws-sns-topic
Terraform Module to Provide an Amazon Simple Notification Service (SNS)
Stars: ✭ 22 (+22.22%)
Mutual labels:  terraform-module
terraform-aws-ecs-web-app
Terraform module that implements a web app on ECS and supports autoscaling, CI/CD, monitoring, ALB integration, and much more.
Stars: ✭ 175 (+872.22%)
Mutual labels:  terraform-module
vim-hcl
Syntax highlighting for HashiCorp Configuration Language (HCL)
Stars: ✭ 83 (+361.11%)
Mutual labels:  hcl

terraform-aws-resource-naming

Terraform Version Release Last Commit Issues Pull Requests License Open Source Love

Table of Content

Prerequisites

  • Terraform
    • This module was created using Terraform 0.11.6 on 2018/04/10
    • The latest stable version of Terraform which this module tested working is Terraform 0.13.7 on 2021/09/15

Quick Start

For most of the resources, AWS does not allow us to create multiple resources with the same name. That is the reason why we need to make them unique.

This module will help you to generate a unique resource name by adding random_id value as a suffix to the name prefix you specified. Not just adding, but this module will also calculate how many random characters should be added to the prefix so it will not exceed maximum character allowed from AWS. Check the list below for AWS services supported by this module.

Supported resources:

  • autoscaling_group
  • autoscaling_policy
  • autoscaling_schedule
  • cloudwatch_event_rule
  • cloudwatch_log_group
  • cloudwatch_metric_alarm
  • codebuild_project
  • codecommit_repository
  • codepipeline
  • db_instance
  • db_parameter_group
  • dynamodb_table
  • ecr_repository
  • ecs_cluster
  • ecs_service
  • ecs_task_definition
  • elasticache_cluster
  • elasticache_parameter_group
  • elasticsearch_domain
  • iam_instance_profile
  • iam_role
  • instance
  • key_pair
  • kinesis_firehose_delivery_stream
  • lambda_function
  • launch_configuration
  • lb
  • lb_target_group
  • s3_bucket
  • secretsmanager_secret
  • security_group
  • sns_topic
  • sqs_queue
  • waf_byte_match_set
  • waf_geo_match_set
  • waf_ipset
  • waf_rate_based_rule
  • waf_regex_match_set
  • waf_regex_pattern_set
  • waf_rule
  • waf_rule_group
  • waf_size_constraint_set
  • waf_sql_injection_match_set
  • waf_web_acl
  • waf_xss_match_set
  • wafregional_byte_match_set
  • wafregional_geo_match_set
  • wafregional_ipset
  • wafregional_rate_based_rule
  • wafregional_regex_match_set
  • wafregional_regex_pattern_set
  • wafregional_rule
  • wafregional_rule_group
  • wafregional_size_constraint_set
  • wafregional_sql_injection_match_set
  • wafregional_web_acl
  • wafregional_xss_match_set

Notes:

  • If character length of your name prefix already exceeds maximum character allowed from AWS, this module will not do anything about it. Executing terraform apply will most likely to fail.

Usage

You need to know what resource you want to provision (resource_type) and what the name prefix (name_prefix) is. Then provide the information to this module's variables:

provider "random" {
  version = ">= 1.2.0, < 3.0.0"
}

module "aws-resource-naming_lambda_role" {
  source        = "github.com/traveloka/terraform-aws-resource-naming"
  version       = "v0.17.1"
  name_prefix   = "LambdaRole_DailyScheduler"
  resource_type = "iam_role"
}

resource "aws_iam_role" "lambda_role" {
  name        = "${module.aws-resource-naming_lambda_role.name}"
  path        = "/lambda-role/"                                       
  description = "Lambda Role for Daily Scheduler"

  assume_role_policy   = "${data.aws_iam_policy_document.lambda_assume_role_policy.json}"
}

data "aws_iam_policy_document" "lambda_assume_role_policy" {
  statement = {
    actions = ["sts:AssumeRole"]
    effect  = "Allow"

    principals = {
      type        = "Service"
      identifiers = ["lambda.amazonaws.com"]
    }
  }
}

To understand better on how to implement this module, you can go into examples folder and try them.

Examples

Module Definition

Requirements

Name Version
terraform >= 0.13

Providers

Name Version
random n/a

Modules

No modules.

Resources

Name Type
random_id.this resource

Inputs

Name Description Type Default Required
keepers Arbitrary map of values that, when changed, will trigger a new id to be generated. map(any) {} no
name_prefix Arbitrary string to prefix the output value with. Adding trailing dash/hypen will not give any effect, it will be added by the module automatically. string n/a yes
resource_type AWS Resource type that the name will be generated by this module. string n/a yes

Outputs

Name Description
name The generated name with random_id presented in padded hexadecimal digits as suffix.

Dependencies

This module does not have any dependencies to other modules.

Contributing

Can not see the resource you want to provision on the list above? Open CONTRIBUTING to learn how to add it by yourself!

License

Apache 2 Licensed. See LICENSE for full details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].