Skip to content

[Feature]: Display OAuth expiration for security integration #3373

Open
@joscha

Description

Company Name

Planet A GmbH

Use Cases or Problem Statement

Airtable support synchronizing data from Snowflake: https://support.airtable.com/docs/airtable-sync-integration-snowflake
This uses an external OAuth token to do so. This token is not refreshed by Airtable, the onus is on the person setting up the integration.
We would love to display when the token expires. The data is available in Snowflake and also in terraform, but it's not entirely usable right now.

Given an integration like this:

resource "snowflake_oauth_integration_for_custom_clients" "airtable_data" {
  provider                   = snowflake.ingest_role
  enabled                    = "true"
  name                       = "airtable_data"
  oauth_client_type          = "CONFIDENTIAL"
  oauth_redirect_uri         = "https://airtable.com/integration/authorize/eatY89uUyfSoAncQS/callback"
  oauth_issue_refresh_tokens = "true"
  # Extended to 365 days via support
  oauth_refresh_token_validity = 31535000
  oauth_use_secondary_roles    = "IMPLICIT"
}

I was hoping to be able to just read the created_on output and add the oauth_refresh_token_validity to it, i.e.:

output "oauth_secret_expiration" {
  value = timeadd(snowflake_oauth_integration_for_custom_clients.airtable_data.show_output[0].created_on, "${snowflake_oauth_integration_for_custom_clients.airtable_data.oauth_refresh_token_validity}s")
}

however, created_on is some mixture of ISO 8601 with a timezone abbreviation or so (YYYY-MM-DD HH24:MI:SS.FF3 TZH TZM)? Thus this fails with:

│ Error: Error in function call
│ 
│   on airtable_sync.tf line 38, in output "oauth_secret_expiration":
│   38:   value = timeadd(snowflake_oauth_integration_for_custom_clients.airtable_data.show_output[0].created_on, "${snowflake_oauth_integration_for_custom_clients.airtable_data.oauth_refresh_token_validity}s")
│     ├────────────────
│     │ while calling timeadd(timestamp, duration)
│     │ snowflake_oauth_integration_for_custom_clients.airtable_data.oauth_refresh_token_validity is 31535000
│     │ snowflake_oauth_integration_for_custom_clients.airtable_data.show_output[0].created_on is "2000-01-01 08:00:50.076 -0800 PST"
│ 
│ Call to function "timeadd" failed: not a valid RFC3339 timestamp: missing required time introducer 'T'.

It would be great if:

  • The resource could provide a expires_on
  • Or there would be a data source for SHOW INTEGRATIONS (where created_on is an actual terraform timestamp, Snowflake itself returns some ISO 8601 but with a TZ identifier and it can't be queried via SELECT * FROM TABLE(RESULT_SCAN(LAST_QUERY_ID())); so using TO_TIMESTAMP_TZ is out of the question, too.)

Category

category:resource

Object type(s)

resource:oauth_integration

Proposal

In order of preference:

  • a synthetic expires_on is exposed
  • there is a integrations data source that has a timestamp for the created_on column.

How much impact is this issue causing?

Low

Additional Information

No response

Would you like to implement a fix?

  • Yeah, I'll take it 😎

Metadata

Assignees

No one assigned

    Labels

    feature-requestUsed to mark issues with provider's missing functionalitiesresource:oauth_integrationIssue connected to the snowflake_oauth_integration resource

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions