StatusCakeDev / terraform-provider-statuscake

Terraform StatusCake provider
https://registry.terraform.io/providers/StatusCakeDev/statuscake/
Mozilla Public License 2.0
35 stars 56 forks source link

Support specifing a workspace #86

Open Tokynet opened 2 years ago

Tokynet commented 2 years ago

I had to create an account in Statuscake, then this account is "invited" into a business subscription (in Statuscake). When I try to deploy resources in the workspace/sub-account I got invited to, the resources are created on the original account and not on the workspace/sub-account one.

Seems there should be a workspace/sub-account option that we can leverage to specify a workspace/sub-account vs the default account.

tomasbasham commented 2 years ago

Hi @Tokynet. This is something we have in the pipeline to be supported by the StatusCake API. Until that is put in place we'll be unable to have workspace support within the Terraform provider.

tomasbasham commented 2 years ago

Right now I'd suggest including multiple instances of the provider, each using authentication tokens belonging to the workspaces that you wish to create resources.

Tokynet commented 2 years ago

Thanks for the prompt response.

I have not seen how to make workspace specific tokens. I have created various tokens but the resources keep landing on the main account.

Could you point me at the documentation for this?

Cheers,

On Thu, Aug 18, 2022, 4:51 AM Tomas Basham @.***> wrote:

Right now I'd suggest including multiple instances of the provider, each using authentication tokens belonging to the workspaces that you wish to create resources.

— Reply to this email directly, view it on GitHub https://github.com/StatusCakeDev/terraform-provider-statuscake/issues/86#issuecomment-1219209335, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACDCAZWV55KZ4MFB2BDPNTVZX2RJANCNFSM56233WWQ . You are receiving this because you were mentioned.Message ID: @.*** com>

tomasbasham commented 2 years ago

Sorry, I probably did a poor job of explaining myself. You'd need to get an API key from the workspace/account you are trying to save the resource on. So you'd need to contact the owner of the workspace you're attempting to access and ask them to generate/give you an API key. I know, this is not very convenient. We're hopefully soon going to be working on making this possible with you own auth tokens.

tomasbasham commented 2 years ago

Something along these lines:

provider "statuscake" {
  api_token = "my-api-token" <--- Your API token
}

provider "statuscake" {
  alias     = "another_workspace"
  api_token = "another-api-token" <--- The API token from the other workspace
}

# This will be saved on your workspace
resource "statuscake_uptime_check" "example_com" {
  # ...
}

# This will be saved on the other workspace
resource "statuscake_uptime_check" "example_com2" {
  provider = statuscake.another_workspace
  # ...
}

If I'm completely honest I have not actually tried this so it may not work. But according to the Terraform docs using alias / provider as meta-parameters should do the trick for now.

Tokynet commented 2 years ago

Thanks for the prompt responses, since I just need to create resources on the other workspace (the one with the paid subscription) I will just leverage the 1 API Token.

Thanks again!