Skip to content

Commit c3ac870

Browse files
committed
Added azure to test CI
1 parent a0a888a commit c3ac870

6 files changed

Lines changed: 49 additions & 16 deletions

File tree

.github/workflows/test.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
JFROG_CREDENTIAL_PLUGIN_BINARY_URL:
66
description: 'BINARY_URL (CI adds arch suffix automatically)'
77
required: true
8-
default: "https://releases.jfrog.io/artifactory/run/jfrog-credentials-provider/0.1.0-beta.1/jfrog-credential-provider-aws-linux"
8+
default: "https://partnership.jfrog.io/artifactory/credential-provider-test/jfrog-credential-provider"
99
type: string
1010
DISABLE_TERRAFORM_DESTROY:
1111
description: 'DISABLE_TERRAFORM_DESTROY'
@@ -42,6 +42,13 @@ jobs:
4242
run: |
4343
aws sts get-caller-identity
4444
45+
- name: Login to Azure with Federated Credentials
46+
uses: azure/login@v1
47+
with:
48+
client-id: ${{ secrets.AZURE_APP_CLIENT_ID }}
49+
tenant-id: ${{ secrets.AZURE_APP_TENANT_ID }}
50+
subscription-id: ${{ secrets.AZURE_APP_SUBSCRIPTION_ID }}
51+
4552
- name: Setup Terraform
4653
uses: hashicorp/setup-terraform@v3
4754
with:
@@ -50,9 +57,13 @@ jobs:
5057

5158
- name: Initialise Terraform
5259
id: init
60+
env:
61+
AZURE_APP_SUBSCRIPTION_ID: ${{ secrets.AZURE_APP_SUBSCRIPTION_ID }}
5362
run: |
5463
echo "" >> build/terraform.tfvars.aws
5564
echo "jfrog_credential_provider_binary_url=\"$JFROG_CREDENTIAL_PLUGIN_BINARY_URL\"" >> build/terraform.tfvars.aws
65+
# for azure, it is not possible to avoid azure authentication check, even when azure is disabled
66+
echo "azure_subscription_id=\"$AZURE_APP_SUBSCRIPTION_ID\"" >> build/terraform.tfvars.aws
5667
cp build/terraform.tfvars.aws terraform-ci/terraform.tfvars
5768
cd terraform-ci
5869
terraform init
@@ -78,7 +89,7 @@ jobs:
7889
if: always()
7990
uses: actions/upload-artifact@v4
8091
with:
81-
name: terraform-context-for-manual-cleanup
92+
name: terraform-context-for-manual-cleanup-aws
8293
path: |
8394
terraform-ci/**/*.tf
8495
terraform-ci/jfrog/*
@@ -97,8 +108,11 @@ jobs:
97108
steps:
98109
- name: Checkout
99110
uses: actions/checkout@v2
111+
112+
- name: Install Azure CLI
113+
uses: pietrobolcato/install-azure-cli-action@main
100114

101-
- name: 'Login to Azure with Federated Credentials'
115+
- name: Login to Azure with Federated Credentials
102116
uses: azure/login@v1
103117
with:
104118
client-id: ${{ secrets.AZURE_APP_CLIENT_ID }}
@@ -113,17 +127,22 @@ jobs:
113127

114128
- name: Initialise Terraform
115129
id: init
130+
env:
131+
AZURE_APP_SUBSCRIPTION_ID: ${{ secrets.AZURE_APP_SUBSCRIPTION_ID }}
116132
run: |
117133
echo "" >> build/terraform.tfvars.azure
118134
echo "jfrog_credential_provider_binary_url=\"$JFROG_CREDENTIAL_PLUGIN_BINARY_URL\"" >> build/terraform.tfvars.azure
135+
echo "azure_subscription_id=\"$AZURE_APP_SUBSCRIPTION_ID\"" >> build/terraform.tfvars.azure
119136
cp build/terraform.tfvars.azure terraform-ci/terraform.tfvars
120137
cd terraform-ci
121138
terraform init
122139
123140
- name: Run Azure Terraform CI
124141
id: apply
125142
run: |
143+
# to avoid credentials check for aws
126144
cd terraform-ci
145+
cat terraform.tfvars
127146
terraform apply -input=false -auto-approve
128147
terraform output -json > terraform_output.json
129148
echo "Terraform output: $(cat terraform_output.json)"
@@ -141,7 +160,7 @@ jobs:
141160
if: always()
142161
uses: actions/upload-artifact@v4
143162
with:
144-
name: terraform-context-for-manual-cleanup
163+
name: terraform-context-for-manual-cleanup-azure
145164
path: |
146165
terraform-ci/**/*.tf
147166
terraform-ci/jfrog/*

build/terraform.tfvars.azure

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,21 @@ self_managed_eks_cluster = {
2222

2323
jfrog_namespace = "jfrog"
2424

25-
region = "ap-northeast-3"
26-
2725
enable_aws = false
2826

2927
enable_azure = true
3028

31-
azure_subscription_id = "6a2a0854-0ddb-4c9d-ac3e-5348c205002c"
32-
3329
azure_resource_group_name = "infra-robin-test"
3430

3531
azure_location = "eastus"
3632

3733
create_aks_cluster = true
3834

39-
aks_cluster_name = "infra-robin-test-aks"
35+
aks_cluster_name = "jfrog-test-aks"
4036

4137
azure_node_count = 3
4238
azure_node_vm_size = "Standard_D2pds_v5"
4339
azure_admin_username = "jfrog"
44-
azure_cluster_public_access_cidrs = ["52.9.243.19/32", "52.215.237.185/32", "13.127.185.21/32"]
40+
41+
# time to live is very short for testing
42+
azure_cluster_public_access_cidrs = ["0.0.0.0/0"]

terraform-ci/azure_identity.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,5 @@ resource "azuread_application_federated_identity_credential" "federated_identity
4646
issuer = "https://login.microsoftonline.com/${data.azuread_client_config.current[0].tenant_id}/v2.0"
4747
subject = data.azurerm_kubernetes_cluster.k8s[0].kubelet_identity[0].object_id
4848

49-
lifecycle {
50-
create_before_destroy = true
51-
}
49+
depends_on = [ azurerm_kubernetes_cluster.k8s, local.azure_app_id, data.azurerm_kubernetes_cluster.k8s[0] ]
5250
}

terraform-ci/eks_nodegroup.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module "eks" {
2929
addons = {
3030
aws-ebs-csi-driver = {
3131
most_recent = true
32-
service_account_role_arn = module.ebs_csi_irsa_role[0].iam_role_arn
32+
service_account_role_arn = module.ebs_csi_irsa_role[0].arn
3333
}
3434
vpc-cni = {
3535
most_recent = true
@@ -111,9 +111,9 @@ module "daemonset_test_ng" {
111111

112112
module "ebs_csi_irsa_role" {
113113
count = var.enable_aws && var.create_eks_cluster ? 1 : 0
114-
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
114+
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts"
115115

116-
role_name = "ebs-csi-role-${local.cluster_name}-${var.region}"
116+
name = "ebs-csi-role-${local.cluster_name}-${var.region}"
117117
attach_ebs_csi_policy = true
118118

119119
oidc_providers = {

terraform-ci/providers.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ terraform {
2929

3030
provider "aws" {
3131
region = var.region
32+
skip_credentials_validation = true
33+
skip_metadata_api_check = true
34+
skip_region_validation = true
35+
skip_requesting_account_id = true
36+
37+
# create a dynamic block to set the access_key, secret_key, and token if they are not null
38+
access_key = var.enable_aws ? null : "foo"
39+
secret_key = var.enable_aws ? null : "bar"
40+
3241
}
3342

3443
provider "azurerm" {
@@ -42,4 +51,5 @@ provider "azurerm" {
4251
}
4352
subscription_id = var.azure_subscription_id
4453
resource_provider_registrations = "none"
54+
4555
}

terraform-module/providers.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,12 @@ terraform {
1717
provider "aws" {
1818
region = var.region
1919
skip_credentials_validation = true
20+
skip_metadata_api_check = true
21+
skip_region_validation = true
22+
skip_requesting_account_id = true
23+
24+
# create a dynamic block to set the access_key, secret_key, and token if they are not null
25+
access_key = var.enable_aws ? null : "foo"
26+
secret_key = var.enable_aws ? null : "bar"
27+
2028
}

0 commit comments

Comments
 (0)