Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: switch to OIDC Federation for Azure #60

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/build_gcp_azure_manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ jobs:
PKR_VAR_image_base_name: spacelift-worker
PKR_VAR_image_family: spacelift-worker
# Azure
PKR_VAR_client_id: ${{ secrets.AZURE_CLIENT_ID }}
PKR_VAR_client_secret: ${{ secrets.AZURE_CLIENT_SECRET }}
PKR_VAR_client_id: "976e4a6e-c619-417e-9add-50e2d674e2db"
PKR_VAR_tenant_id: ${{ secrets.AZURE_TENANT_ID }}
PKR_VAR_subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
PKR_VAR_oidc_request_url: "${ACTIONS_ID_TOKEN_REQUEST_URL}"
PKR_VAR_oidc_request_token: "${ACTIONS_ID_TOKEN_REQUEST_TOKEN}"
PKR_VAR_image_resource_group: rg-worker_images-public-westeurope
PKR_VAR_packer_work_group: rg-worker_images_packer-public-westeurope
PKR_VAR_gallery_resource_group: rg-worker_images-public-westeurope
Expand Down Expand Up @@ -74,7 +75,7 @@ jobs:
- name: Azure => Build the AMI using Packer
if: matrix.cloud == 'azure'
run: packer build azure.pkr.hcl

- name: GCP => Build the AMI using Packer for US
if: matrix.cloud == 'gcp'
run: packer build gcp.pkr.hcl
Expand Down Expand Up @@ -152,9 +153,9 @@ jobs:

content = fs.readFileSync("./manifest_gcp.json", "utf8");
manifest = JSON.parse(content);

const gcpLinesToPrint = [];

manifest["builds"].forEach((build) => {
artifact = build["artifact_id"];
if (artifact.indexOf("-us-") > 0) {
Expand All @@ -167,7 +168,7 @@ jobs:
gcpLinesToPrint.push(` - Asia | \`${artifact}\``);
}
});

console.log("## Azure");
console.log("");
console.log(`- Publisher | \`spaceliftinc1625499025476\`.`);
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
matrix:
cloud: [aws, azure, gcp]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
env:
# AWS
PKR_VAR_encrypt_boot: false
Expand All @@ -24,10 +27,11 @@ jobs:
PKR_VAR_image_base_name: spacelift-worker
PKR_VAR_image_family: spacelift-worker
# Azure
PKR_VAR_client_id: ${{ secrets.AZURE_CLIENT_ID }}
PKR_VAR_client_secret: ${{ secrets.AZURE_CLIENT_SECRET }}
PKR_VAR_client_id: "433d3ca3-1866-4dfa-b9bf-65d6c4391ec7"
PKR_VAR_tenant_id: ${{ secrets.AZURE_TENANT_ID }}
PKR_VAR_subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
PKR_VAR_oidc_request_url: "${ACTIONS_ID_TOKEN_REQUEST_URL}"
PKR_VAR_oidc_request_token: "${ACTIONS_ID_TOKEN_REQUEST_TOKEN}"
PKR_VAR_image_resource_group: rg-worker_images-public-westeurope
PKR_VAR_packer_work_group: rg-worker_images_packer-public-westeurope
PKR_VAR_gallery_resource_group: rg-worker_images-public-westeurope
Expand Down
16 changes: 11 additions & 5 deletions azure.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ variable "client_id" {
default = ""
}

variable "client_secret" {
variable "oidc_request_url" {
type = string
default = ""
}

variable "oidc_request_token" {
type = string
default = ""
}
Expand Down Expand Up @@ -97,10 +102,11 @@ variable "packer_work_group" {
}

source "azure-arm" "spacelift" {
client_id = var.client_id
client_secret = var.client_secret
subscription_id = var.subscription_id
tenant_id = var.tenant_id
client_id = var.client_id
subscription_id = var.subscription_id
tenant_id = var.tenant_id
oidc_request_url = var.oidc_request_url
oidc_request_token = var.oidc_request_token

managed_image_name = var.image_name
managed_image_resource_group_name = var.image_resource_group
Expand Down