Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beanstalk created resources naming should be configurable independently #172

Open
florian0410 opened this issue Mar 11, 2021 · 0 comments
Open

Comments

@florian0410
Copy link
Contributor

florian0410 commented Mar 11, 2021

Describe the Feature

When creating a new beanstalk environment, some resources naming should be configurable independently from each other with a custom name.

Expected Behavior

For created EC2 instances, S3 Bucket, instance_profile, iam_roles, there should be a configuration that let us custom their name.
Like the s3_bucket_access_log_bucket_name variable.

We could use these to customize our resources naming.

Use Case

We are currently starting to use this module to deploy Beanstalk but we have specifics constraints on naming for our resources :

For EC2 : Product-Component-Environment-Blue_Green
For IAM Roles: Product-Component-Environment-AWS::Region
For S3: Product-Component-Environment-AWS::AccountId-AWS::Region

Since we are doing multi-regions deployments, there are main patterns standards we need to respect to ensure consistent naming of our resources. As you can see they are similar and could be implemented using context module mechanics but not the exact same.

Problem the module use the same naming pattern for these ressources.

name = "${module.this.id}-eb-service"

name = "${module.this.id}-eb-ec2"

name = "${module.this.id}-eb-default"

name = "${module.this.id}-eb-ec2"

bucket = "${module.this.id}-eb-loadbalancer-logs"

For S3 we clearly need account ID in name to avoid conflicts since it's a global resource, same goes for IAM roles but not EC2 name which is specifics to the account.

Describe Ideal Solution

Being able to specify an alternative name to these resources as variable.
For example we could have these variables to specify explicit name:

  • iam_role_service_name
  • iam_role_ec2_name
  • iam_role_policy_default_name
  • iam_instance_profile_ec2_name
  • s3_bucket_elb_logs_bucket_name

Or maybe being able to specify a prefix or a global naming convention for each type of resource.

Alternatives Considered

Before opening this feature request I tried to use attributes option and label_order from context module.

var.tfvars

...
product = "product"
component = "component"
environment = "env"
label_order = ["namespace", "name", "environment", "attributes"]
...

main.tf

module "elastic_beanstalk_environment" {
  ...
  label_order = var.label_order
  attributes   = [data.aws_caller_identity.current.account_id,var.region]
  ...

Plan give me

Beanstalk env name: product-comp-env-862853942159-eu-west-1
ec2 name: product-comp-env-862853942159-eu-west-1-eb-ec2
ec2 iam instance: product-comp-env-862853942159-eu-west-1-eb-ec2
iam role service: product-comp-env-862853942159-eu-west-1-eb-service
s3 bucket for logs: product-comp-env-862853942159-eu-west-1-eb-loadbalancer-logs

Which allow us at least to respect widely our convention but flood some resources naming with useless information.

Additional Context

S3 limitation to 63 chars for bucket name make it hard to name our Bucket since the module append the -eb-loadbalancer-logs field consuming 21 chars of the 63 available.

This would require another issue I think but since we could replace it with this features it's good information.

I was thinking about using multiple context module to solve this but it's not possible in the end since there is a single one referenced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant