Skip to Content
Cloud Engineering Academy
13. Microsoft-to-AWS Migration

DevOps, IaC and secrets side by side: Azure DevOps, Bicep and Key Vault vs AWS

Translate Azure DevOps pipelines, service connections, ARM and Bicep deployments and Key Vault into GitHub Actions or CodePipeline, OIDC-assumed roles, CloudFormation or CDK change sets, and Secrets Manager with KMS, and decide what to migrate first and what to leave in place.

intermediate⏱ 1 h 30 min🟢 FreeDOP-C02SAA-C03SCS-C03

Assumes: .NET 10 LTS · AWS SDK for .NET v4 (AWSSDK.SecretsManager) · AWS CDK v2 (C#) · AWS CLI v2 · GitHub Actions with OIDC · Region us-east-1. Verified against official sources on 2026-11-18.

Learning objectives

By the end of this lesson you can:

  • Map Azure DevOps concepts (pipelines, stages, service connections, variable groups, environments, artifact feeds) to GitHub Actions or the AWS Code services.
  • Replace a long-lived service connection secret with an OIDC-assumed IAM role.
  • Translate a Bicep template into AWS CDK (C#), and use change sets where you used what-if.
  • Map Key Vault secrets, keys and certificates to Secrets Manager, KMS and ACM, including access control, soft delete and rotation.
  • Decide the order in which to migrate pipelines, IaC and secrets, and what may safely stay on Azure for a while.

Prerequisites

Why this matters in banking

Pipelines and secrets are the keys to production. A bank's change process says who may deploy, with what evidence. Harbourline's Azure DevOps pipelines deploy through a service connection with a client secret that expires every two years and is stored by three people. Key Vault holds database passwords that the pipelines read. A migration plan that says "recreate pipelines in GitHub Actions and copy the secrets" quietly changes who can deploy, where the secrets live, and what the audit trail looks like, all at once.

The safe approach is to change one dimension at a time, keep evidence continuous, and remove standing secrets instead of copying them. This lesson gives the map and the order.

The idea in plain language

Three jobs, each with an Azure tool and an AWS tool:

  1. Pipeline: build, test and deliver the code. Azure DevOps Pipelines; on AWS, GitHub Actions (the default in this course) or CodePipeline with CodeBuild and CodeDeploy.
  2. Infrastructure as code (IaC): describe the cloud resources in files. ARM and Bicep; on AWS, CloudFormation, AWS CDK (write in C#) or Terraform.
  3. Secrets: keep passwords, keys and certificates out of code. Key Vault; on AWS, Secrets Manager (secrets), KMS (encryption keys) and ACM (certificates).

Analogy: the pipeline is the delivery van, IaC is the building plan, and secrets are the keys held by the security desk. You can move to a new city's van company (pipeline) without touching the plan or the key safe, and you should: changing all three at once is how keys get lost.

What problem the AWS services solve

AWS serviceProblemLimits and sharp edges
GitHub Actions + OIDCPipelines with no stored cloud keys; each run gets short-lived credentials from a roleTrust policy conditions (repository, branch, environment) must be tight; see OIDC lesson
CodePipeline, CodeBuild, CodeDeployAWS-native pipeline, build and deploy with IAM-based accessAnother system to learn; pipelines are defined as AWS resources
CloudFormationDeclarative stacks with change sets, drift detection and rollbackJSON/YAML only; stack limits apply ⚠ VERIFY the current resource-per-stack limit
AWS CDK (C#)Write infrastructure in C# that synthesises to CloudFormationNeeds cdk bootstrap per account and Region; generated templates are CloudFormation
Secrets ManagerStored, encrypted, rotatable secrets with IAM and auditBilled per secret per month plus API calls; one secret is capped at 64 KB ⚠ VERIFY
KMSEncryption keys with key policies and auditA customer managed key costs about USD 1 a month plus requests ⚠ VERIFY
ACMFree public TLS certificates for integrated services (ALB, CloudFront, API Gateway)Cannot export public certificates; private CAs are a paid separate service

Microsoft / Azure comparison

Pipelines

You know (Azure DevOps)AWS or GitHub equivalentWhat's different
Pipeline YAML, stages, jobs, stepsGitHub Actions workflow, jobs, steps; or CodePipeline stages and actionsActions YAML is similar; steps are actions or shell commands
Task (marketplace)Action (uses:)Pin third-party actions to full commit SHAs
Service connection (service principal secret or workload identity)IAM role assumed with OIDC (aws-actions/configure-aws-credentials)No secret to rotate; the trust policy names the repository and branch
Variable groups and secret variablesRepository or environment variables; secrets pulled from Secrets Manager at runtimeKeep cloud secrets in AWS, not in the CI vendor
Environments with approvals and checksGitHub Environments with required reviewers; the role trust can require the environment nameApproval evidence lives in GitHub; export it for audit
Agent pools (Microsoft-hosted, self-hosted)GitHub-hosted runners, self-hosted runners, or CodeBuild computeSelf-hosted runners in a VPC can reach private resources
Artifacts and Azure Artifacts feedsECR (images), CodeArtifact (NuGet, npm and other packages), S3 for build outputsCodeArtifact needs a short-lived token; see the CLI section
Azure ReposGitHub (this course's default). CodeCommit is generally available again since 2025-11-24A repository host is a business decision; do not migrate repos and pipelines in one step
Azure BoardsNot an AWS serviceKeep your work tracker; link commits to tickets
Release gates, deployment ringsCodeDeploy deployment groups and traffic shifting, ECS strategiesSee ECS deployment strategies

Infrastructure as code

You know (ARM / Bicep)AWS equivalentWhat's different
ARM template, Bicep fileCloudFormation template; CDK app (C#); Terraform configurationNo automatic converter from Bicep to CloudFormation; you re-author
Resource group deploymentStackA stack is the unit of create, update and delete
az deployment group what-ifChange set (aws cloudformation deploy --no-execute-changeset) or cdk diffChange sets show replace versus update; read them before executing
Incremental mode (default) / complete modeStack manages exactly the resources in its templateResources removed from the template are deleted from the stack
Modules, template specsCDK constructs, CloudFormation modules, Service Catalog productsIn CDK, a construct is a class; reuse is normal C# packaging
Parameters, parameter filesCDK context and props, CloudFormation parameters, SSM parametersPrefer typed props in CDK
Deployment historyCloudFormation stack events and change set historyEnable termination protection on production stacks
Azure Policy for IaC guardrailscdk-nag, CloudFormation Guard, SCPsSee policy as code
Drift (manual changes)Drift detectionRun it on a schedule; it reports, it does not fix

Secrets and keys

You know (Key Vault)AWS equivalentWhat's different
SecretsSecrets Manager secrets (JSON, string or binary)Versions use staging labels (AWSCURRENT, AWSPREVIOUS)
Keys (RSA, EC, AES; HSM-backed)KMS keys (symmetric, asymmetric, HMAC) and CloudHSM for dedicated HSMsKMS keys never leave the service; you call encrypt and decrypt
CertificatesACM (public TLS) or ACM Private CACertificates are attached to services; you rarely handle the private key
Access policies or Azure RBAC on the vaultIAM policy on the caller plus resource policy on the secret and key policy on the KMS keyKMS key policies are the root of key access; IAM alone is not enough ⚠ read the key policy rules
Soft delete, purge protectionSecrets Manager recovery window (7 to 30 days; default 30)Force-delete skips it; do not allow force-delete in production
Rotation (Event Grid trigger plus a function)Secrets Manager rotation with a Lambda; managed rotation for supported database enginesRotation needs network access from the Lambda to the database
Key Vault reference in app settingsECS task definition secrets, Beanstalk environment secrets, Lambda extensionInjected at start; rotation needs a refresh strategy
App ConfigurationParameter Store or AWS AppConfigParameter Store is free for standard parameters and fine for non-secret settings
DefaultAzureCredential + SecretClientAWS SDK default credential chain + AmazonSecretsManagerClientIdentical shape; the role is the identity

Architecture

Security-boundary view. There are three identities: the pipeline role (can deploy, cannot read production secrets), the application's task role (can read its own secrets, cannot deploy) and human operators (Identity Center, read-only by default). The KMS key policy lets only the application role decrypt. Compare that with an Azure DevOps service connection that often holds Contributor on a whole subscription.

Migration order that works

  1. Identity and landing zone first (accounts, roles, SCPs).
  2. IaC next: re-author the base network and shared services in CDK or Terraform, because everything else needs them.
  3. Secrets: create them in AWS fresh (new values, rotated) rather than exporting from Key Vault. A migration is the best time to rotate.
  4. Pipelines last, one application at a time. Azure DevOps can deploy to AWS during the transition, which means no big-bang CI/CD change. ⚠ VERIFY whether you use the AWS Toolkit for Azure DevOps or plain CLI steps with a federated identity.

Step-by-step implementation

Inventory pipelines, secrets and service connections

For each pipeline: triggers, stages, approvals, service connections and the scopes each holds. For each Key Vault: secrets, keys, certificates, access policies, who reads them, rotation. Highlight any secret older than a year.

Create the OIDC provider and deploy role

Create the GitHub OIDC identity provider in the AWS account and a deploy role whose trust policy pins repository, branch or environment. The full walkthrough, including the hostile-token tests, is in Lab 9.2.

Port one pipeline

Translate stages to jobs. Replace the service connection step with configure-aws-credentials. Keep approvals as GitHub Environments. The workflow in Complete code is the template.

Re-author the IaC

Start with a stateless piece (a bucket, a queue). Use cdk diff as your what-if. For existing resources you do not want to recreate, plan a controlled import rather than a rewrite.

Move secrets with rotation

Create each secret in Secrets Manager with a customer managed KMS key, grant read access to the application role only, change the application to read it, then rotate the value and retire the Key Vault copy.

Run both in parallel and compare

Deploy the same commit through the old and new pipelines to non-production, compare outputs and logs, then switch production one application at a time.

AWS Console instructions

  • Secrets Manager: Console → Secrets Manager → Store a new secret, choose the secret type, pick a customer managed KMS key (create one in Console → KMS → Customer managed keys), name it hl/m13/ledger/db, optionally configure rotation.
  • CloudFormation change set: Console → CloudFormation → Stacks → (stack) → Change sets → Create change set; read each row for Modify versus Replacement.
  • OIDC provider: Console → IAM → Identity providers → Add provider → OpenID Connect, provider URL https://token.actions.githubusercontent.com, audience sts.amazonaws.com.

AWS CLI

# Preview a CloudFormation deployment without executing it: the Bicep "what-if" equivalent.
aws cloudformation deploy --template-file template.yaml --stack-name hl-m13-secrets \
  --no-execute-changeset --capabilities CAPABILITY_NAMED_IAM \
  --profile learn-sandbox --region us-east-1

# Create a secret encrypted with your own KMS key. (Value shown is a placeholder: never type real credentials into a shell history.)
aws secretsmanager create-secret --name hl/m13/ledger/db \
  --secret-string '{"username":"app_user","password":"CHANGE_ME_PLACEHOLDER"}' \
  --kms-key-id alias/hl-m13-secrets \
  --tags Key=Project,Value=cea-lab Key=Lab,Value=m13-devops Key=Environment,Value=learn \
  --profile learn-sandbox --region us-east-1

# Look at metadata only (does not print the secret value).
aws secretsmanager describe-secret --secret-id hl/m13/ledger/db --profile learn-sandbox --region us-east-1

# CodeArtifact: a short-lived NuGet/npm token replaces a long-lived Azure Artifacts PAT (if you adopt CodeArtifact).
aws codeartifact get-authorization-token --domain hl-domain --query authorizationToken --output text \
  --profile learn-sandbox --region us-east-1 >/dev/null && echo "token obtained"

Infrastructure as Code

The Bicep you may have today, and its CDK (C#) and Terraform equivalents. The Bicep is shown for comparison only.

Bicep (before)
param location string = resourceGroup().location

resource kv 'Microsoft.KeyVault/vaults@2023-07-01' = {
  name: 'hl-ledger-kv'
  location: location
  properties: {
    sku: { family: 'A', name: 'standard' }
    tenantId: subscription().tenantId
    enableRbacAuthorization: true
    enableSoftDelete: true
    enablePurgeProtection: true
  }
}
SecretsStack.cs
using Amazon.CDK;
using Amazon.CDK.AWS.IAM;
using Amazon.CDK.AWS.KMS;
using Amazon.CDK.AWS.SecretsManager;
using Constructs;

public sealed class SecretsStack : Stack
{
    public SecretsStack(Construct scope, string id, IStackProps props) : base(scope, id, props)
    {
        // The vault becomes two things: a key (who may decrypt) and a secret (the value).
        var key = new Key(this, "SecretsKey", new KeyProps
        {
            Alias = "alias/hl-m13-secrets",
            EnableKeyRotation = true,
            RemovalPolicy = RemovalPolicy.DESTROY, // learning lab only; production RETAIN
        });

        var secret = new Secret(this, "LedgerDb", new SecretProps
        {
            SecretName = "hl/m13/ledger/db",
            EncryptionKey = key,
            // Generates a random password so no human ever sees it.
            GenerateSecretString = new SecretStringGenerator
            {
                SecretStringTemplate = "{\"username\":\"app_user\"}",
                GenerateStringKey = "password",
                ExcludePunctuation = true,
                PasswordLength = 32,
            },
        });

        // The application role may read this one secret (CDK also adds the KMS permission it needs).
        var appRole = new Role(this, "AppRole", new RoleProps
        {
            AssumedBy = new ServicePrincipal("ecs-tasks.amazonaws.com"),
        });
        secret.GrantRead(appRole);

        Amazon.CDK.Tags.Of(this).Add("Project", "cea-lab");
        Amazon.CDK.Tags.Of(this).Add("Lab", "m13-devops");
        Amazon.CDK.Tags.Of(this).Add("Environment", "learn");
    }
}

Complete code

The Azure DevOps pipeline being replaced (comparison only):

azure-pipelines.yml (before)
trigger: [main]
stages:
  - stage: Build
    jobs:
      - job: build
        pool: { vmImage: ubuntu-latest }
        steps:
          - task: UseDotNet@2
            inputs: { version: 10.0.x }
          - script: dotnet test --solution Ledger.slnx
  - stage: Deploy
    dependsOn: Build
    jobs:
      - deployment: deploy
        environment: ledger-test        # approvals configured on the environment
        strategy:
          runOnce:
            deploy:
              steps:
                - task: AzureCLI@2      # service connection with a stored secret
                  inputs:
                    azureSubscription: ledger-conn
                    scriptType: bash
                    scriptLocation: inlineScript
                    inlineScript: az deployment group create -g ledger-rg -f main.bicep

The GitHub Actions replacement, with OIDC and a diff before deploy:

.github/workflows/deploy-test.yml
name: deploy-test
on:
  push:
    branches: [main]

permissions:
  id-token: write   # lets the job request an OIDC token
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7            # pin to a full commit SHA in real use
      - uses: actions/setup-dotnet@v5        # pin to a full commit SHA in real use
        with:
          dotnet-version: 10.0.x
      - run: dotnet test --solution Ledger.slnx

  deploy-test:
    needs: build
    runs-on: ubuntu-latest
    environment: ledger-test                  # required reviewers are configured here
    steps:
      - uses: actions/checkout@v7
      - uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
        with:
          role-to-assume: arn:aws:iam::111122223333:role/hl-m13-deploy-test
          aws-region: us-east-1
      - run: npx cdk diff
      - run: npx cdk deploy --require-approval never

The account ID is a placeholder. The actions/* tags are shown for readability; check the current versions and pin full commit SHAs ⚠ VERIFY.

Reading the secret in the application, mirroring DefaultAzureCredential plus SecretClient:

DbSecret.cs
using System.Text.Json;
using Amazon.SecretsManager;
using Amazon.SecretsManager.Model;

public sealed record DbCredentials(string Username, string Password);

public sealed class DbSecretReader(IAmazonSecretsManager sm)
{
    // Azure (before): new SecretClient(vaultUri, new DefaultAzureCredential()).GetSecretAsync("ledger-db")
    // AWS (after): the SDK finds the task role from the environment; the role is the identity.
    public async Task<DbCredentials> ReadAsync(string secretId, CancellationToken ct)
    {
        var response = await sm.GetSecretValueAsync(new GetSecretValueRequest { SecretId = secretId }, ct);
        using var doc = JsonDocument.Parse(response.SecretString);
        return new DbCredentials(
            doc.RootElement.GetProperty("username").GetString()!,
            doc.RootElement.GetProperty("password").GetString()!);
    }
}

For production reads, use the caching client or an in-process cache with a short time to live, as shown in the Secrets Manager lesson.

Code explained line by line

  1. permissions: id-token: write allows the job to request a GitHub OIDC token. Without it the credentials step fails. contents: read limits the default token.
  2. The build job runs tests with no cloud access at all. Separating it from the deploy job means a compromised test dependency never sees a cloud role.
  3. environment: ledger-test is where approvals and environment-scoped rules apply. The AWS trust policy can require this environment name in the token's sub claim.
  4. configure-aws-credentials exchanges the OIDC token for temporary credentials by assuming the role. There is no stored key. The commit SHA pin protects against a tampered tag.
  5. cdk diff is the what-if step: reviewers see replacements before cdk deploy.
  6. In DbSecretReader, GetSecretValueAsync retrieves the current version. The constructor takes IAmazonSecretsManager so tests can pass a fake.
  7. The CDK GenerateSecretString makes Secrets Manager create the password, so it never appears in code, logs or state files.

Security considerations

⚠ Learning shortcut — not for production

The lab secret uses a 7-day recovery window or immediate deletion, the KMS key has RemovalPolicy.DESTROY, and the workflow deploys with --require-approval never. Production uses RETAIN on keys and secrets, a recovery window of 30 days with force-delete denied by SCP, required reviewers on production environments, a separate deploy role per environment with a trust policy pinned to the exact repository, branch and environment, and a reviewed cdk diff or change set as the change-board artefact.

  • Do not export Key Vault secrets in bulk. Create new values in AWS and rotate. A copied secret keeps its old exposure history.
  • No secrets in pipeline variables for AWS: let the pipeline assume a role and let the application read the secret itself.
  • Key policy discipline. The KMS key policy must name the application role for decrypt; the deploy role should be able to manage the key without being able to use it.
  • Separation of duties. The person who approves a production deployment should not be the one who wrote the change. Enforce with branch protection and environment reviewers; evidence lives in the run history and CloudTrail.
  • Audit trail. CloudTrail records AssumeRoleWithWebIdentity and every GetSecretValue. Retain it according to your records policy. This lesson does not claim any regulatory standard is met.

Banking use case

Harbourline's change board requires, for every production release: who approved, what changed, and proof the deployer could not read customer data. The new flow gives all three. The approver is the GitHub Environment reviewer (recorded by GitHub); the change is the cdk diff output archived as a build artefact; and the deploy role has no secretsmanager:GetSecretValue or kms:Decrypt, so it can create the secret's resource but never read its value. Azure DevOps keeps running the legacy applications' pipelines until their wave, deploying to AWS with the same OIDC-style federation where supported ⚠ VERIFY, or with a short-lived role assumed in a script step.

Common mistakes

  • Migrating pipelines, IaC and secrets in one go. If it breaks, nobody knows which change caused it. Sequence them.
  • Copying the service principal secret into GitHub. It defeats the point. Use OIDC.
  • Treating cdk deploy --require-approval never as safe. It is fine for sandboxes; production needs reviewed diffs.
  • Trusting repo:org/* in the OIDC trust policy. Any repository in the organisation can then assume the role. Pin the repository and branch or environment.
  • Reading secrets on every request. It costs money and adds latency; cache briefly.
  • Rotating without testing the application. A rotated password breaks connection pools that never refresh.

Troubleshooting

SymptomLikely causeFix
Not authorized to perform sts:AssumeRoleWithWebIdentityTrust policy sub or aud does not match the tokenCompare the token claims with the trust conditions; see Lab 9.2
Credentials could not be loaded in the jobid-token: write permission missingAdd the permission at workflow or job level
AccessDeniedException reading a secretTask role lacks secretsmanager:GetSecretValue or the key policy omits itGrant read on the secret and decrypt on the key
cdk diff shows replacement of a databaseA property change forces replacementStop; plan a controlled migration instead of deploying
Secret deleted but name unusableThe secret is in its recovery windowRestore it, or use --force-delete-without-recovery in the lab only
Pipeline passes in Azure DevOps but fails in ActionsDifferent default shell, path or tool versionPin tool versions explicitly in both

Cost and cleanup

Cost label: free for the pipeline and CLI work. A Secrets Manager secret is billed per secret per month (about USD 0.40) and a customer managed KMS key about USD 1 a month, prorated hourly; both are small if destroyed the same day ⚠ VERIFY current prices. Free alternative: store non-secret settings in Parameter Store standard parameters, and do the secret exercise as a design.

# CDK route
cdk destroy SecretsStack --profile learn-sandbox

# CLI route for a lab secret (skips the recovery window: lab only)
aws secretsmanager delete-secret --secret-id hl/m13/ledger/db --force-delete-without-recovery \
  --profile learn-sandbox --region us-east-1

# KMS keys are scheduled for deletion, not deleted at once (minimum waiting period is 7 days)
aws kms schedule-key-deletion --key-id alias/hl-m13-secrets --pending-window-in-days 7 \
  --profile learn-sandbox --region us-east-1

# Verify what remains
aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=cea-lab \
  --profile learn-sandbox --region us-east-1 --query "ResourceTagMappingList[].ResourceARN"

A key pending deletion stops billing for the monthly key fee after deletion completes; check Console → KMS to confirm its state.

Exercises

  • 🟢 Guided: run cdk diff (or cdk synth) on SecretsStack, then explain what each resource in the output replaces from the Bicep example.
  • 🟡 Challenge: write the OIDC trust policy for a role that only the main branch of harbourline/ledger can assume for the ledger-test environment, and list the three claims it checks.
  • 🔴 Live problem: the security team found that an Azure DevOps service connection has Owner on the production subscription and its secret is in a wiki page. You are asked to "fix this as part of the AWS migration". Propose what you would do in the first week, what you would leave alone, and how you would show an auditor the old secret was revoked.

Assignment

Produce a DevOps migration card for one real pipeline: current stages and approvals, service connections and their scopes, secrets used, target workflow, target role and trust policy, IaC approach, and rollback. Commit it, with the translated workflow, to your portfolio repository.

Solutions

Knowledge check

Interview questions

  • "How do pipelines authenticate to AWS without stored keys?" OIDC federation: the runner presents a signed token, STS validates it against the provider and the trust policy's conditions, and returns short-lived credentials for a role.
  • "What do you migrate first, the pipeline or the infrastructure code?" Infrastructure code, because pipelines deploy it; keep the old pipeline running to avoid changing two things at once.
  • "How do you stop the deploy role from reading production secrets?" Do not grant GetSecretValue or kms:Decrypt to it; the key policy lists only the application role for decrypt.

Certification practice

Completion checklist

  • I can map five Azure DevOps concepts to GitHub Actions or AWS equivalents
  • I can explain why OIDC replaces a service connection secret
  • I ran cdk diff or cdk synth for the secrets stack
  • I scheduled deletion of the KMS key and removed the secret, then ran the tag query

Key takeaways

  • One dimension at a time: identity, then IaC, then secrets, then pipelines.
  • OIDC roles replace service connection secrets; the trust policy is the control.
  • Change sets and cdk diff are the what-if; read them for replacements.
  • A vault becomes three AWS concerns: Secrets Manager, KMS and IAM or key policies.
  • Rotate during migration; never bulk-copy secrets.

Further reading

Independent learning resource — not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.

On this page