Skip to content

Update wif_util.py create_attestation #2315

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/snowflake/connector/wif_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
from base64 import b64encode
from dataclasses import dataclass
from collections import defaultdict
from enum import Enum, unique

import boto3
Expand Down Expand Up @@ -304,18 +305,18 @@ def create_attestation(
If an explicit entra_resource was provided to the connector, this will be used. Otherwise, the default Snowflake Entra resource will be used.
"""
entra_resource = entra_resource or DEFAULT_ENTRA_SNOWFLAKE_RESOURCE

attestation: WorkloadIdentityAttestation = None
if provider == AttestationProvider.AWS:
attestation = create_aws_attestation()
elif provider == AttestationProvider.AZURE:
attestation = create_azure_attestation(entra_resource)
elif provider == AttestationProvider.GCP:
attestation = create_gcp_attestation()
elif provider == AttestationProvider.OIDC:
attestation = create_oidc_attestation(token)
elif provider is None:
attestation = create_autodetect_attestation(entra_resource, token)
provider_map = (
lambda: None,
{
AttestationProvider.AWS: lambda: create_aws_attestation(),
AttestationProvider.AZURE: lambda: create_azure_attestation(entra_resource),
AttestationProvider.GCP: lambda: create_gcp_attestation(),
AttestationProvider.OIDC: lambda: create_oidc_attestation(token),
None: lambda: create_autodetect_attestation(entra_resource, token)
}
)
attestation: WorkloadIdentityAttestation = provider_map(provider)

if not attestation:
provider_str = "auto-detect" if provider is None else provider.value
Expand Down