Skip to content

feat(auth): Add native GitLab CI OIDC provider #3207

Open
knmiguel/atmos
#1

Description

@knmiguel

Describe the Feature

Add native support for GitLab CI/CD OIDC authentication to the Atmos authentication framework, similar to the existing github/oidc provider.

GitLab CI can issue OIDC ID tokens for jobs using the id_tokens configuration. These tokens can be used to authenticate to cloud providers such as AWS without storing long-lived credentials in GitLab CI/CD variables.

It would be useful if Atmos could consume a GitLab-issued OIDC token directly and use it as an authentication provider, for example:

auth:
  providers:
    gitlab-oidc:
      kind: gitlab/oidc
      region: eu-west-1

  identities:
    deploy:
      kind: aws/assume-role
      via:
        provider: gitlab-oidc
      principal:
        assume_role: arn:aws:iam::123456789012:role/GitLabDeployRole

This would provide the GitLab equivalent of the existing github/oidc provider.

Expected Behavior

Atmos should be able to authenticate from a GitLab CI job using a GitLab-issued OIDC ID token and use that identity to assume an AWS IAM role.

A GitLab pipeline could configure an ID token:

deploy:
  id_tokens:
    ATMOS_OIDC_TOKEN:
      aud: sts.amazonaws.com

  script:
    - atmos terraform apply mycomponent -s prod

Atmos would then use the GitLab OIDC token when resolving an identity backed by a gitlab/oidc provider.

Ideally this would work with the existing Atmos identity model, including role chaining:

auth:
  providers:
    gitlab-oidc:
      kind: gitlab/oidc
      region: eu-west-1

  identities:
    gitlab-runner:
      kind: aws/assume-role
      via:
        provider: gitlab-oidc
      principal:
        assume_role: arn:aws:iam::111111111111:role/GitLabRunnerRole

    production:
      kind: aws/assume-role
      via:
        identity: gitlab-runner
      principal:
        assume_role: arn:aws:iam::222222222222:role/AtmosDeployRole

No static AWS access keys would need to be stored in GitLab.

Use Case

We use Atmos from GitLab CI to deploy Terraform resources across multiple AWS accounts.

We want authentication to be based entirely on short-lived credentials and workload identity rather than GitLab CI/CD secrets containing AWS credentials.

GitLab supports issuing OIDC ID tokens to individual CI jobs, and AWS IAM supports trusting GitLab as an OIDC identity provider. This provides a strong trust model because the AWS role trust policy can restrict access using claims such as project, namespace, branch, environment, or other GitLab token claims.

Atmos already provides a native github/oidc provider for this type of workflow when running in GitHub Actions. We would like to use the same Atmos authentication and identity abstraction when running Atmos in GitLab CI.

This becomes especially useful in multi-account environments where Atmos identities can represent the roles used to deploy into different AWS accounts.

Without native support, part of the authentication process has to be implemented outside Atmos even though Atmos otherwise provides the identity and role chaining model.

Describe Ideal Solution

Introduce a new authentication provider:

kind: gitlab/oidc

with behavior comparable to github/oidc.

For example:

auth:
  providers:
    gitlab:
      kind: gitlab/oidc
      region: eu-west-1
      spec:
        token_environment_variable: ATMOS_OIDC_TOKEN

  identities:
    deploy:
      kind: aws/assume-role
      via:
        provider: gitlab
      principal:
        assume_role: arn:aws:iam::123456789012:role/GitLabDeployRole

The provider could:

  • Read a GitLab OIDC ID token from an environment variable created through GitLab's id_tokens configuration.
  • Use the token with AWS STS AssumeRoleWithWebIdentity.
  • Avoid caching the GitLab OIDC token or credentials derived from it.
  • Work with the existing aws/assume-role identity implementation.
  • Support chaining from the initial OIDC-authenticated role into additional AWS roles/accounts.
  • Allow the token environment variable to be configured explicitly.
  • Optionally provide sensible GitLab CI defaults when GITLAB_CI=true is detected.

For example, the complete GitLab job could be as small as:

deploy:
  id_tokens:
    ATMOS_OIDC_TOKEN:
      aud: sts.amazonaws.com

  script:
    - atmos terraform apply mycomponent -s prod --identity deploy

with the AWS role and authentication configuration remaining entirely in Atmos.

It would also be useful if the provider could eventually support GitLab.com as well as self-managed GitLab instances, since the OIDC issuer URL can differ between installations.

Alternatives Considered

Configure AWS authentication outside Atmos

The GitLab job can manually exchange the GitLab OIDC token for AWS credentials and export:

AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_SESSION_TOKEN

before invoking Atmos.

This works, but it means the authentication logic lives partly in .gitlab-ci.yml and partly in Atmos.

Use AWS_WEB_IDENTITY_TOKEN_FILE

Another option is to write the GitLab ID token to a file and configure the standard AWS environment variables:

AWS_ROLE_ARN
AWS_WEB_IDENTITY_TOKEN_FILE

and let the AWS SDK credential chain resolve the credentials.

Again, this works, but bypasses Atmos' authentication provider abstraction.

Additional Context

Atmos already supports GitHub Actions OIDC through:

auth:
  providers:
    github-oidc:
      kind: github/oidc

GitLab provides the same underlying workload identity capability through CI/CD ID tokens.

The GitLab side can look like:

deploy:
  id_tokens:
    ATMOS_OIDC_TOKEN:
      aud: sts.amazonaws.com

  script:
    - atmos terraform apply mycomponent -s prod

and the corresponding AWS IAM OIDC trust can restrict which GitLab projects, branches, tags, or environments are permitted to assume a role.

Supporting this natively would allow teams using GitLab CI to use Atmos' authentication and identity system in the same way GitHub Actions users can, while avoiding long-lived cloud credentials in CI/CD.

Activity

  1. osterman commented on Sep 30, 2026

    @osterman
    Member

    knmiguel we are interested in supporting this. Would you be willing to burn some tokens to help us implement this?

  2. knmiguel commented on Oct 5, 2026

    @knmiguel
    Author

    knmiguel we are interested in supporting this. Would you be willing to burn some tokens to help us implement this?

    Sure, I'd be willing to give this a try and work on a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions