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

Add resource to create an API key for managed grafana #26374

Closed
allenhumphreys opened this issue Aug 18, 2022 · 5 comments · Fixed by #25286
Closed

Add resource to create an API key for managed grafana #26374

allenhumphreys opened this issue Aug 18, 2022 · 5 comments · Fixed by #25286
Labels
enhancement Requests to existing resources that expand the functionality or scope. new-resource Introduces a new resource. service/grafana Issues and PRs that pertain to the grafana service.

Comments

@allenhumphreys
Copy link

allenhumphreys commented Aug 18, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

I'm trying to create a managed Grafana instance using the AWS provider and then manage the Grafana dashboards/etc using the Grafana provider.

In order for the Grafana provider to authenticate with the Grafana instance, it needs to have an API key. As part of my infrastructure configuration, I'd like to ensure my Grafana provider can have access to an API.

The goal would be to use aws_grafana_workspace_api_key to create an admin key, store it in Secrets Manager, and then read that value as part of my Dashboard terraform configuration.

New or Affected Resource(s)

  • aws_grafana_workspace_api_key
  • aws_grafana_workspace (needs to export the workspace_id for use with the new resource)

Potential Terraform Configuration

resource "aws_grafana_workspace" "example" {
  account_access_type      = "CURRENT_ACCOUNT"
  authentication_providers = ["SAML"]
  permission_type          = "SERVICE_MANAGED"
  role_arn                 = aws_iam_role.assume.arn
}

resource "aws_grafana_workspace_api_key" "terraform" {
  workspace_id = aws_grafana_workspace.example.workspace_id
  name            = "${var.environment}-terraform-api-key"
  role            = "Admin"
  seconds_to_live = 2592000 ### 1 month
}

resource "aws_secretsmanager_secret" "grafana-key" {
  name                    = "${var.environment}-grafana-key"
  recovery_window_in_days = 0
}

resource "aws_secretsmanager_secret_version" "grafana-key" {
  secret_id     = aws_secretsmanager_secret.grafana-key.id
  secret_string = jsonencode({
    key   = "${var.environment}-grafana-secret"
    value = aws_grafana_workspace_api_key.terraform
  })
}

References

@allenhumphreys allenhumphreys added the enhancement Requests to existing resources that expand the functionality or scope. label Aug 18, 2022
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/grafana Issues and PRs that pertain to the grafana service. service/secretsmanager Issues and PRs that pertain to the secretsmanager service. labels Aug 18, 2022
@breathingdust breathingdust added new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels Aug 18, 2022
@bschaatsbergen
Copy link
Member

bschaatsbergen commented Aug 18, 2022

Hi @allenhumphreys, thanks for raising this issue. I'll happily look into this.

@allenhumphreys
Copy link
Author

@bschaatsbergen that’s amazing, your time is appreciated!

@bschaatsbergen
Copy link
Member

With a pleasure @allenhumphreys, the PR is out 🚀 !

@ewbankkit ewbankkit removed the service/secretsmanager Issues and PRs that pertain to the secretsmanager service. label Aug 22, 2022
@allenhumphreys
Copy link
Author

Turns out this was a duplicate of #25100 all along

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. new-resource Introduces a new resource. service/grafana Issues and PRs that pertain to the grafana service.
Projects
None yet
4 participants