<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Surya Teja Avirneni</title>
    <description>The latest articles on DEV Community by Surya Teja Avirneni (@suryateja_avirneni_95455).</description>
    <link>https://dev.to/suryateja_avirneni_95455</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3022129%2F9c30ad1a-d2ae-4049-b055-f879597e3528.jpeg</url>
      <title>DEV Community: Surya Teja Avirneni</title>
      <link>https://dev.to/suryateja_avirneni_95455</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/suryateja_avirneni_95455"/>
    <language>en</language>
    <item>
      <title>Secretless CI/CD with GitHub Actions OIDC</title>
      <dc:creator>Surya Teja Avirneni</dc:creator>
      <pubDate>Fri, 25 Apr 2025 15:58:27 +0000</pubDate>
      <link>https://dev.to/suryateja_avirneni_95455/secretless-cicd-with-github-actions-oidc-1np2</link>
      <guid>https://dev.to/suryateja_avirneni_95455/secretless-cicd-with-github-actions-oidc-1np2</guid>
      <description>&lt;p&gt;Managing AWS credentials for CI/CD pipelines can quickly become complex and risky. Hardcoding AWS credentials or storing them as GitHub Secrets exposes your organization to credential leakage, auditability challenges, and significant security risks. Similarly, statically binding IAM roles to runners complicates scaling, limits flexibility, and creates management overhead — especially in multi-account environments.&lt;/p&gt;

&lt;p&gt;In this tutorial, you'll learn how to securely manage AWS access from GitHub Actions using AWS Attribute-Based Access Control (ABAC), GitHub Actions OIDC tokens, and Amazon Cognito as an identity broker — all without static credentials or brittle IAM bindings. This model maps OIDC claims from your CI/CD workflows to a short-lived AWS STS token. This model can be extended to any service provider that you need to connect to from your CI/CD workflows, as long as the service provider is OIDC compliant and supports Identity Federation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Avoid Hardcoded Credentials and Static IAM Bindings?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Security Risks:&lt;/strong&gt; Hardcoded secrets can leak through logs, repos, or misconfigurations.&lt;br&gt;
&lt;strong&gt;Auditability Issues:&lt;/strong&gt; Static credentials obscure who performed actions and when.&lt;br&gt;
&lt;strong&gt;Operational Bottlenecks:&lt;/strong&gt; Static role-to-runner bindings make it hard to scale access across apps or environments.&lt;/p&gt;

&lt;p&gt;If you’re scaling GitHub Actions across multiple teams, apps, or accounts — you need a better way. A least privileged access model along with dynamic infrastructure scaling. &lt;/p&gt;
&lt;h2&gt;
  
  
  Secure, Scalable Architecture Overview
&lt;/h2&gt;

&lt;p&gt;This architecture connects GitHub Actions to AWS securely using temporary session credentials based on identity claims and session tags.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GitHub Actions → [OIDC Token] 
     ↓
Cognito Identity Pool → [Maps Claims → Principal Tags]
     ↓
AWS STS → [AssumeRoleWithWebIdentity → Session with Tags]
     ↓
AWS Resources (enforced via ABAC)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step-by-Step Setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Create an OIDC Identity Provider for GitHub
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Resources:
  GitHubOIDCProvider:
    Type: AWS::IAM::OIDCProvider
    Properties:
      Url: https://token.actions.githubusercontent.com
      ClientIdList:
        - "sts.amazonaws.com"
      ThumbprintList:
        - "6938fd4d98bab03faadb97b34396831e3780aea1"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;You can also configure this manually via the IAM Console → Identity Providers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2. Configure Cognito Identity Pool
&lt;/h3&gt;

&lt;p&gt;Map OIDC claims from GitHub into principal tags.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Resources:
  IdentityPool:
    Type: AWS::Cognito::IdentityPool
    Properties:
      IdentityPoolName: GitHubActionsABAC
      AllowClassicFlow: true
      OpenIdConnectProviderARNs:
        - !GetAtt GitHubOIDCProvider.Arn
      PrincipalTags:
        repository: "repo:repository"
        environment: "repo:environment"
        workflow: "repo:job_workflow_ref"

  IdentityPoolRoleAttachment:
    Type: AWS::Cognito::IdentityPoolRoleAttachment
    Properties:
      IdentityPoolId: !Ref IdentityPool
      Roles:
        authenticated: !GetAtt ABACRole.Arn

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Define the ABAC IAM Role
&lt;/h3&gt;

&lt;p&gt;This IAM role uses session tags for authorization.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Resources:
  ABACRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: GitHubActionsABACRole
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal:
              Federated: cognito-identity.amazonaws.com
            Action: sts:AssumeRoleWithWebIdentity
            Condition:
              StringEquals:
                cognito-identity.amazonaws.com:aud: !Ref IdentityPool
      Policies:
        - PolicyName: ABACDynamicAccess
          PolicyDocument:
            Version: "2012-10-17"
            Statement:
              - Effect: Allow
                Action: "*"
                Resource: "*"
                Condition:
                  StringEquals:
                    aws:ResourceTag/Repository: "${aws:PrincipalTag/repository}"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. GitHub Actions Workflow with OIDC → Cognito
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: ABAC Deployment
on: [push]

permissions:
  id-token: write
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Configure AWS Credentials via Cognito
        uses: catnekaise/cognito-idpool-auth@v2
        with:
          auth-flow: enhanced
          cognito-identity-pool-id: ${{ secrets.COGNITO_POOL_ID }}
          aws-region: us-west-2
          set-in-environment: true

      - name: Deploy Resources
        run: |
          aws s3api create-bucket --bucket my-bucket \
            --tagging "Repository=${{ github.repository }}"

          # ✅ Allowed: bucket tagged correctly
          aws s3 ls s3://my-bucket

          # ❌ Denied: bucket with incorrect tag
          aws s3 ls s3://other-bucket

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How It Works: Identity and Tags in Action
&lt;/h2&gt;

&lt;p&gt;GitHub OIDC Claims:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "repository": "org/my-repo",
  "environment": "prod",
  "job_workflow_ref": ".github/workflows/deploy.yml"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These map into:&lt;/p&gt;

&lt;p&gt;Cognito Principal Tags: repository, environment, workflow&lt;br&gt;
AWS Session Tags: Used in IAM policies to enforce access&lt;/p&gt;
&lt;h2&gt;
  
  
  Real-World Scenario: Multi-Account, Multi-App
&lt;/h2&gt;

&lt;p&gt;ABAC lets you scale your platform securely:&lt;/p&gt;

&lt;p&gt;Multi-account CI/CD: Assign different roles for dev/stage/prod accounts.&lt;br&gt;
Shared runners: Let multiple apps use the same runners — securely and in isolation.&lt;br&gt;
No over-permissioning: Runners don’t get ambient access to resources.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GitHub Actions
   ↓
Cognito Identity Pool
   ├─ Dev Role → Dev Resources
   └─ Prod Role → Prod Resources

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Benefits Recap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;No long-lived AWS credentials in GitHub&lt;/li&gt;
&lt;li&gt;Least-privilege access per job, repo, or environment&lt;/li&gt;
&lt;li&gt;Clean audit trail — every access mapped to identity&lt;/li&gt;
&lt;li&gt;Flexible scaling for CI/CD across teams and cloud accounts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_abac.html" rel="noopener noreferrer"&gt;AWS ABAC Overview&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect" rel="noopener noreferrer"&gt;GitHub Actions OIDC&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-identity.html" rel="noopener noreferrer"&gt;AWS Cognito Identity Pools&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Secure your GitHub Actions pipelines the right way — with identity, not secrets.&lt;/p&gt;

</description>
      <category>secretless</category>
      <category>cicd</category>
      <category>aws</category>
      <category>abac</category>
    </item>
  </channel>
</rss>
