terraform-provider-statuscake icon indicating copy to clipboard operation
terraform-provider-statuscake copied to clipboard

Support specifing a workspace

Open Tokynet opened this issue 3 years ago • 6 comments

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.

Tokynet avatar Aug 17 '22 20:08 Tokynet

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 avatar Aug 18 '22 08:08 tomasbasham

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.

tomasbasham avatar Aug 18 '22 08:08 tomasbasham

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>

Tokynet avatar Aug 18 '22 11:08 Tokynet

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 avatar Aug 18 '22 12:08 tomasbasham

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.

tomasbasham avatar Aug 18 '22 12:08 tomasbasham

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!

Tokynet avatar Aug 18 '22 13:08 Tokynet