Is it possible to update environment variables in ...
# dagster-plus
z
Is it possible to update environment variables in Dagster Cloud via the graphQL interface or programmatically in general? I took a quick look at the GraphQL playground and didn't see anything for mutating / updating env vars, but might have just missed it
s
Hey Zach, unfortunately this gets a little hairy... but here are some mutations that another customer put together. By chance, if we had a CLI command that let you sync env vars from a local file would that be useful to you?
Copy code
mutation CreateSecret($secretName: String!, $secretValue: String!, $scopes: SecretScopesInput!, $locationNames: [String!]!) {
    createSecret(secretName: $secretName, secretValue: $secretValue, scopes: $scopes, locationNames: $locationNames) {
        __typename
        ... on CreateOrUpdateSecretSuccess {
            secret {
                id
                secretName
                secretValue

                updatedBy {
                    email
                }
                updateTimestamp

                locationNames

                fullDeploymentScope
                allBranchDeploymentsScope
                specificBranchDeploymentScope
                localDeploymentScope
            }
        }
        ...on UnauthorizedError {
            message
        }
        ...on TooManySecretsError {
            message
        }
        ...on InvalidSecretInputError {
            message
        }
        ... on PythonError {
            message
            stack
        }
    }
}

mutation DeleteSecret($secretId: String!) {
    deleteSecret(secretId: $secretId) {
        __typename
        ... on DeleteSecretSuccess {
            secretId
        }
        ...on UnauthorizedError {
            message
        }
        ... on PythonError {
            message
            stack
        }
    }
}
    
query AllSecretsQuery {
    secretsOrError {
        __typename
        ... on Secrets {
            secrets {
                id
                secretName
                secretValue

                updatedBy {
                    email
                }
                updateTimestamp

                locationNames

                fullDeploymentScope
                allBranchDeploymentsScope
                specificBranchDeploymentScope
                localDeploymentScope
                canViewSecretValue
                canEditSecret
            }
        }
        ...on UnauthorizedError {
            message
        }
        ... on PythonError {
            message
            stack
        }
    }
}
mutation UpdateSecret($secretId: String!, $secretName: String!, $secretValue: String!, $scopes: SecretScopesInput!, $locationNames: [String!]!) {
    updateSecret(secretId: $secretId, secretName: $secretName, secretValue: $secretValue, scopes: $scopes, locationNames: $locationNames) {
        __typename
        ... on CreateOrUpdateSecretSuccess {
            secret {
                id
                secretName
                secretValue

                updatedBy {
                    email
                }
                updateTimestamp

                locationNames

                fullDeploymentScope
                allBranchDeploymentsScope
                specificBranchDeploymentScope
                localDeploymentScope
            }
        }
        ...on UnauthorizedError {
            message
        }
        ...on TooManySecretsError {
            message
        }
        ...on InvalidSecretInputError {
            message
        }
        ... on PythonError {
            message
            stack
        }
    }
}
z
That's super helpful thanks, I can add these to my graphql client. I think a feature on the CLI to enable this would work - we just have a number of configuration parameters that get updated by external processes and would like to be able to deploy changes to those parameters programmatically through our CI/CD
plus1 1
s
This is sort of what those inputs look like:
Copy code
mutation_variables = {
    "secretName"  = "password"
    "secretValue" = "a_secret_password"
    "scopes" = jsonencode({
      "fullDeploymentScope"       = true
      "allBranchDeploymentsScope" = true 
      "localDeploymentScope"      = false
    })
    "locationNames" = jsonencode([
      "location1", "location2"
    ])
👍 3
m
@Sean Lopp I echo this use case. I think being able to use the cli to create/update/delete parameters would be extremely helpful. For reference: https://dagster.slack.com/archives/C02LJ7G0LAZ/p1693260803939629