Compare commits

...

10 Commits

6 changed files with 45 additions and 32 deletions

View File

@ -17,7 +17,7 @@ jobs:
e2e-check: e2e-check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: environment:
name: acctests name: test
steps: steps:
- name: Checking for Fork - name: Checking for Fork
shell: pwsh shell: pwsh
@ -32,11 +32,12 @@ jobs:
- name: Get changed files - name: Get changed files
if: github.event.pull_request.head.repo.fork == false if: github.event.pull_request.head.repo.fork == false
id: changed-files id: changed-files
uses: tj-actions/changed-files@v34 uses: tj-actions/changed-files@v45
with: with:
dir_names: "true" dir_names: true
separator: "," separator: ","
files: "quickstart/*" dir_names_include_files: "quickstart/*"
files: "quickstart/**"
files_ignore: "**/TestRecord.md" files_ignore: "**/TestRecord.md"
dir_names_max_depth: 2 dir_names_max_depth: 2
- name: test pr - name: test pr

View File

@ -15,11 +15,12 @@ jobs:
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3.6.0 uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3.6.0
- name: Get changed files - name: Get changed files
id: changed-files id: changed-files
uses: tj-actions/changed-files@716b1e13042866565e00e85fd4ec490e186c4a2f #v41.0.1 uses: tj-actions/changed-files@v45
with: with:
dir_names: "true" dir_names: true
separator: "," separator: ","
files: "quickstart/*" dir_names_include_files: "quickstart/*"
files: "quickstart/**"
dir_names_max_depth: 2 dir_names_max_depth: 2
- name: pr-check - name: pr-check
run: | run: |

View File

@ -5,7 +5,7 @@ terraform {
required_providers { required_providers {
azurerm = { azurerm = {
source = "hashicorp/azurerm" source = "hashicorp/azurerm"
version = "~>2.0" version = "~>3.0"
} }
azapi = { azapi = {
source = "Azure/azapi" source = "Azure/azapi"
@ -27,7 +27,11 @@ terraform {
} }
provider "azurerm" { provider "azurerm" {
features {} features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
} }
resource "random_pet" "id" {} resource "random_pet" "id" {}
@ -88,20 +92,18 @@ resource "azurerm_lb_backend_address_pool" "bpepool" {
} }
resource "azurerm_lb_probe" "vmss" { resource "azurerm_lb_probe" "vmss" {
resource_group_name = azurerm_resource_group.vmss.name
loadbalancer_id = azurerm_lb.vmss.id loadbalancer_id = azurerm_lb.vmss.id
name = "ssh-running-probe" name = "ssh-running-probe"
port = var.application_port port = var.application_port
} }
resource "azurerm_lb_rule" "lbnatrule" { resource "azurerm_lb_rule" "lbnatrule" {
resource_group_name = azurerm_resource_group.vmss.name
loadbalancer_id = azurerm_lb.vmss.id loadbalancer_id = azurerm_lb.vmss.id
name = "http" name = "http"
protocol = "Tcp" protocol = "Tcp"
frontend_port = var.application_port frontend_port = var.application_port
backend_port = var.application_port backend_port = var.application_port
backend_address_pool_id = azurerm_lb_backend_address_pool.bpepool.id backend_address_pool_ids = [azurerm_lb_backend_address_pool.bpepool.id]
frontend_ip_configuration_name = "PublicIPAddress" frontend_ip_configuration_name = "PublicIPAddress"
probe_id = azurerm_lb_probe.vmss.id probe_id = azurerm_lb_probe.vmss.id
} }
@ -217,7 +219,7 @@ resource "azurerm_network_interface" "jumpbox" {
ip_configuration { ip_configuration {
name = "IPConfiguration" name = "IPConfiguration"
subnet_id = azurerm_subnet.vmss.id subnet_id = azurerm_subnet.vmss.id
private_ip_address_allocation = "dynamic" private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.jumpbox.id public_ip_address_id = azurerm_public_ip.jumpbox.id
} }

View File

@ -35,6 +35,15 @@ variable "image_resource_group_name" {
default = "myPackerImages" default = "myPackerImages"
} }
variable "oidc_request_url" {
default = null
}
variable "oidc_request_token" {
default = null
}
# arm builder
source "azure-arm" "builder" { source "azure-arm" "builder" {
client_id = var.client_id client_id = var.client_id
client_secret = var.client_secret client_secret = var.client_secret
@ -47,6 +56,8 @@ source "azure-arm" "builder" {
os_type = "Linux" os_type = "Linux"
subscription_id = var.subscription_id subscription_id = var.subscription_id
tenant_id = var.tenant_id tenant_id = var.tenant_id
oidc_request_url = var.oidc_request_url
oidc_request_token = var.oidc_request_token
vm_size = "Standard_DS2_v2" vm_size = "Standard_DS2_v2"
azure_tags = { azure_tags = {
"dept" : "Engineering", "dept" : "Engineering",

View File

@ -27,10 +27,6 @@ var speicalTests = map[string]func(*testing.T){
func Test_Quickstarts(t *testing.T) { func Test_Quickstarts(t *testing.T) {
t.Parallel() t.Parallel()
msiId := os.Getenv("MSI_ID")
if msiId != "" {
_ = os.Setenv("TF_VAR_msi_id", msiId)
}
input := os.Getenv("CHANGED_FOLDERS") input := os.Getenv("CHANGED_FOLDERS")
folders := strings.Split(input, ",") folders := strings.Split(input, ",")
if input == "" { if input == "" {
@ -115,22 +111,24 @@ func test201VmssPackerJumpbox(t *testing.T) {
packerVars := map[string]string{ packerVars := map[string]string{
"image_resource_group_name": imageResourceGroupName, "image_resource_group_name": imageResourceGroupName,
} }
useMsi := false
if clientId := os.Getenv("ARM_CLIENT_ID"); clientId != "" { if clientId := os.Getenv("ARM_CLIENT_ID"); clientId != "" {
packerVars["client_id"] = clientId packerVars["client_id"] = clientId
} }
if os.Getenv("MSI_ID") != "" {
useMsi = true
}
if clientSecret := os.Getenv("ARM_CLIENT_SECRET"); clientSecret != "" { if clientSecret := os.Getenv("ARM_CLIENT_SECRET"); clientSecret != "" {
packerVars["client_secret"] = clientSecret packerVars["client_secret"] = clientSecret
} }
if subscriptionId := os.Getenv("ARM_SUBSCRIPTION_ID"); subscriptionId != "" { if subscriptionId := os.Getenv("ARM_SUBSCRIPTION_ID"); subscriptionId != "" {
packerVars["subscription_id"] = subscriptionId packerVars["subscription_id"] = subscriptionId
} }
if tenantId := os.Getenv("ARM_TENANT_ID"); !useMsi && tenantId != "" { if tenantId := os.Getenv("ARM_TENANT_ID"); tenantId != "" {
packerVars["tenant_id"] = tenantId packerVars["tenant_id"] = tenantId
} }
if oidcRequestToken := os.Getenv("ARM_OIDC_REQUEST_TOKEN"); oidcRequestToken != "" {
packerVars["oidc_request_token"] = oidcRequestToken
}
if oidcRequestUrl := os.Getenv("ARM_OIDC_REQUEST_URL"); oidcRequestUrl != "" {
packerVars["oidc_request_url"] = oidcRequestUrl
}
patches := gomonkey.ApplyFunc(shell.RunCommandAndGetOutputE, func(t terratest.TestingT, command shell.Command) (string, error) { patches := gomonkey.ApplyFunc(shell.RunCommandAndGetOutputE, func(t terratest.TestingT, command shell.Command) (string, error) {
output, err := shell.RunCommandAndGetStdOutE(t, command) output, err := shell.RunCommandAndGetStdOutE(t, command)
if err != nil { if err != nil {