alexcasalboni / aws-lambda-power-tuning

AWS Lambda Power Tuning is an open-source tool that can help you visualize and fine-tune the memory/power configuration of Lambda functions. It runs in your own AWS account - powered by AWS Step Functions - and it supports three optimization strategies: cost, speed, and balanced.
Apache License 2.0
5.29k stars 363 forks source link

Possibility to override role path (Terraform) #170

Closed ldcorentin closed 2 years ago

ldcorentin commented 2 years ago

Hello guys!

I add a new variable role_path_prefix so we can override the path in every roles that the module creates.

Thanks for the review 🙏

alexcasalboni commented 2 years ago

Hi @ldcorentin 👋 Thanks for contributing to Lambda Power Tuning 🙏

I think this is a useful addition.

Because it's a full override, maybe should we rename the variable from role_path_prefix to role_path_override? Something like this:

locals {
  role_path = format("/%s/", var.role_path_override != null ? var.role_path_override : var.lambda_function_prefix)
}

resource "aws_iam_role" "executor_role" {
  ...
  path = local.role_path
}

Alternatively, we could make it an actual prefix. Something like this:

locals {
  role_path = format("/%s%s/", var.role_path_prefix != null ? "${var.role_path_prefix}/" : "", var.lambda_function_prefix)
}

resource "aws_iam_role" "executor_role" {
  ...
  path = local.role_path
}

Which one works better for you? Do you need full control over the role path or are you ok with just enforcing a prefix?

ldcorentin commented 2 years ago

Hey, sorry I was off.

I do need to have the control over the role path because I have restriction and some roles need to have an empty path.

This is why I did :

var.role_path_prefix != "" ? var.role_path_prefix : "/${var.lambda_function_prefix}/"
alexcasalboni commented 2 years ago

Thanks for the update @ldcorentin 🙏

Only a couple of minor changes required, then I'll be happy to merge 🎉

ldcorentin commented 2 years ago

Thanks for the review @alexcasalboni 🙏

alexcasalboni commented 2 years ago

some roles need to have an empty path

@ldcorentin did you test this implementation with an empty path? Or by empty you mean "/"?

ldcorentin commented 2 years ago

@alexcasalboni By empty, I meant "/", sorry for the confusion I introduced

alexcasalboni commented 2 years ago

Happy to merge this! 🎉 🙏