How I eliminated access keys from my deployment pipeline with OIDC, Terraform, and GitHub Actions
Jenkins
Source: Dev.to | Jan 23, 2026 (UTC)
The Problem with Traditional CI/CD
Most tutorials for deploying static sites to AWS tell you to:
Generate AWS access keys
Store them as GitHub secrets
Hope nobody compromises your repository
This approach has serious security implications. Long-lived credentials in CI/CD pipelines are a common attack vector since if your repository is compromised or secrets are accidentally exposed, attackers gain full AWS access with those credentials.
There’s a better way: OpenID Connect (OIDC) federation.
What I Built
A fully automated static website deployment pipeline that eliminates access keys entirely by using temporary credentials exchanged through OIDC.
Here’s something that tripped me up: S3 website endpoints require custom origin configuration, not standard S3 origin configuration.
# This doesn't work for S3 website endpoints origin { domain_name = aws_s3_bucket.website_storage.bucket_regional_domain_name origin_id = "S3-Website" s3_origin_config { origin_access_identity = aws_cloudfront_origin_access_identity.default.cloudfront_access_identity_path } } # This works for the s3 website endpoints origin { domain_name = aws_s3_bucket.website_storage.website_endpoint origin_id = "S3-Website" custom_origin_config { http_port = 80 https_port = 443 origin_protocol_policy = "http-only" origin_ssl_protocols = ["TLSv1.2"] } }
Enter fullscreen mode
Exit fullscreen mode
Why? S3 website endpoints function as HTTP servers, supporting redirects and error documents. Standard S3 origins access the S3 API directly and don’t support these features.
5. Remote State Management
For production infrastructure, always use remote state with locking:
Deployment time: Approximately 30 seconds from commit to live site (measured from workflow logs).
Cost Analysis
One of the best parts? This infrastructure costs almost nothing to run.
Monthly costs (based on January 2026 AWS pricing):
Service
Usage
Cost
S3 Storage
<1GB
$0.02
S3 Requests
10k/month
$0.05
CloudFront
10GB transfer
$0.85
Total
~$0.92/month
For comparison, a single t3.micro EC2 instance costs $8-15/month and requires active management. .
AWS’s eventually consistent nature means public access settings must be applied before the bucket policy.
Security Wins
This architecture eliminates several attack vectors:
No long-lived credentials – temporary credentials expire in 1 hour
Repository-scoped access – only your specific repo can deploy
Branch-specific trust – only main branch can trigger deployments
Least-privilege permissions – role can only write to specific S3 bucket
Encrypted state – Terraform state encrypted at rest in S3
No credential rotation – AWS handles credential lifecycle automatically
The current implementation shows:
Infrastructure as Code proficiency
Cloud security best practices
CI/CD automation
Cost optimization awareness
Conclusion
OIDC federation with GitHub Actions is the modern standard for CI/CD authentication to AWS. It’s more secure, requires zero maintenance, and is easier to implement than managing long-lived access keys.
If you’re still using AWS access keys in your deployment pipelines, it’s time to upgrade.
Try it yourself: Fork the repository, update the variables, and deploy your own infrastructure in under 5 minutes.
Залишити відповідь