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

feature: init version #1

Merged
merged 5 commits into from
Mar 5, 2024
Merged

feature: init version #1

merged 5 commits into from
Mar 5, 2024

Conversation

gberenice
Copy link
Member

Info

  • This adds an initial datadog-users module version. It allows creating only Datadog Standard Role and should be extended in the future to handle more cases.
  • The module uses our terraform-secrets-helper and expects SOPS to be configured.

@gberenice gberenice requested a review from a team March 5, 2024 15:16
send_user_invitation = each.value.send_user_invitation

lifecycle {
ignore_changes = [name]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's include a comment on why we lifecycle ignore name. I think it's because it gets sets to the users email or something until they first sign in?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any naming modifications in our Clients' Datadog. Also, couldn't find any explanation why it was added initially.
I removed this lifecycle, because we can't explain why this is here.

Copy link
Member

@Gowiem Gowiem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gberenice looking good! Few requests, but overall this was thorough and well done!

main.tf Outdated
disabled = each.value.disabled
email = each.value.email
name = each.value.name
roles = [data.datadog_role.standard.id]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should work to provide some mapping to the other roles as well -- Just including the standard feels like we're not providing a complete module since we know we've used the others elsewhere. Mind adding that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gowiem the reason I didn't add the mapping is that currently we use the following schema for access_roles:

  - username: veronika.gnilitska
    name: Veronika Gnilitska
    ...
    access_roles:
      aws: false
      datadog: true

So datadog is just enabled or disabled.
I can update this module to support out-of-the-box roles, something like:

    access_roles:
      datadog: 
         enabled: true
         role: [standard | ro | admin]

And after that - updated our team.yaml.
How does that sound?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added support for the out-of-the-box roles. Let me know your thoughts.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this access_roles shouldn't be here at all. I'll push some changes soon.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gowiem okay, I think I cleaned this out.
I'd love to work on tests and things like that, let's discuss the priority on our next call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sounds good!

variables.tf Outdated Show resolved Hide resolved
examples/complete/secrets.sops.tf Show resolved Hide resolved
Comment on lines 1 to 2
datadog_api_key: ENC[AES256_GCM,data:joPOPI58VO5E2g==,iv:G3BamrS3ANDMhJqjyZbn1YhAqf2GJ7g7DdVivrYVzDw=,tag:k2sGvVtoxznn7U8x8I7oUw==,type:int]
datadog_app_key: ENC[AES256_GCM,data:GeerHEomnls2Cg==,iv:9uiNp5vvv/8/6sqNix28FRm1btWy6CF3fnGD3RV3oMI=,tag:LbGRJu7Bz8HdJYR+6iO/vQ==,type:int]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you create a test datadog account? Because if so... bravo 😁

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, no. We don't have tests yet, so I decided to use a decryptable SOPS file example. SOPS with age doesn't depend on any cloud resource and is good for these types of things.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all for using age here, makes sense 👍

We should spin up a internal DD org so we can test this module, even if those are tests are manual for now. We could also create some terraform test blocks as well...

Let's talk about this Thursday.

README.md Outdated Show resolved Hide resolved
providers.tf Outdated Show resolved Hide resolved
outputs.tf Outdated Show resolved Hide resolved
@gberenice gberenice force-pushed the feature/init_version branch from 998e298 to 4f7ce9b Compare March 5, 2024 18:45
versions.tf Outdated Show resolved Hide resolved
variables.tf Outdated Show resolved Hide resolved
main.tf Outdated Show resolved Hide resolved
main.tf Show resolved Hide resolved
data.tf Show resolved Hide resolved
@gberenice gberenice force-pushed the feature/init_version branch from 3e5c7cc to 8857106 Compare March 5, 2024 19:19
Comment on lines +11 to +14
validation {
condition = alltrue([for role in flatten([for user in var.users : user.roles]) : contains(["standard", "admin", "read_only"], role)])
error_message = "Each role must be one of 'standard', 'admin', or 'read_only'."
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌 🙌 🙌

Copy link
Member

@Gowiem Gowiem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome -- well done Veronika! One request and then we'll get it shipped!

for_each = local.users
disabled = each.value.disabled
email = each.value.email
name = each.value.name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea with lifecycle_ignore on the name was that users can change their name in the console and it causes a recreate or drift in the resource. We shouldn't care about how they want to spell their names or how they change them so we lifecycle ignored it... I'm thinking we add that back and make that clear via a comment. Sorry to reverse!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay. I've never seen that users actually care about that 😆 , but it's a valid point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. Sorry, this has been a bit hectic 😬

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gberenice hectic? We just very quickly iterated on a bunch of good changes on this PR. This was kinda how I want all PRs to go. Things are going to need to change. We should be bringing up all of our thoughts on what is good practice or what we expect and then having fast feedback loops on iterating on those changes. This was great, hats off to you on doing things quickly and responding correctly to feedback 💯

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gowiem thanks for the great feedback!

Copy link
Member

@Gowiem Gowiem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOLID WORK, LGTM!

@gberenice gberenice merged commit 83331e5 into main Mar 5, 2024
2 checks passed
@gberenice gberenice deleted the feature/init_version branch March 5, 2024 20:01
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

Successfully merging this pull request may close these issues.

2 participants