Skip to content

NOVA-411: Hello World migrations, Bicep to Terraform & Selenium to Playwright#7

Open
hugoglez-nc wants to merge 64 commits intomainfrom
to-terraform
Open

NOVA-411: Hello World migrations, Bicep to Terraform & Selenium to Playwright#7
hugoglez-nc wants to merge 64 commits intomainfrom
to-terraform

Conversation

@hugoglez-nc
Copy link
Contributor

Migration to Terraform and Playwright

Infrastructure (Bicep → Terraform)

  • Replaced Infrastructure/Pipelines/container-app.bicep with Terraform modules in Infrastructure/Terraform/
  • Pipeline now uses Terraform Plan → Apply → Destroy workflow with unique state files per build (helloworld-{env}-{buildId}.tfstate)
  • Backend configured for Azure Storage with dynamic container_name based on EnvironmentName parameter
  • Maintains same Container App configuration (managed identity, ACR integration, port 8080)

Testing (Selenium → Playwright)

  • Migrated HelloWorld.IntegrationTests/ from NUnit + Selenium (Chrome) to NUnit + Playwright
  • Replaced WebDriver element lookups with Playwright's built-in locators (e.g., Page.Locator("#brandLink"))
  • Simplified test setup: Playwright auto-manages browsers, no more ChromeDriver version mismatches
  • Cross-browser ready: currently uses Chromium, easily extensible to Firefox/WebKit

Breaking Changes

  • None for the app itself—same ASP.NET Core 8 MVC with identical element IDs in _Layout.cshtml
  • Pipeline requires Terraform backend configured in Azure Storage (see providers.tf)
  • Local test execution now requires pwsh playwright.ps1 install instead of Chrome/ChromeDriver

Updated Docs

  • Infrastructure/Terraform/README.md documents pipeline integration and backend configuration

server: containerRegistryLoginServer
username: containerRegistryUsername
passwordSecretRef: 'registry-password'
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add backlog to switch to managed identity

]
scale: {
minReplicas: 1
maxReplicas: 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backlog generic http traffic keda scaling rule?

ManagedIdentityResourceGroupName: 'rg-dev-devops-usc'
ContainerRegistryLoginServer: 'ncontracts.azurecr.io'
AzureResourceManagerSC: 'Dev-Limited'
ContainerRegistrySC: 'NContractsSC'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use managed idenitity instead

Copy link
Contributor Author

@hugoglez-nc hugoglez-nc Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean use "mi-dev-devops-usc" instead of "NContractsSC"?
I tried that, but task Docker@2 expects a service connection, so the option is to create a new service connection using the new managed identity.

workingDirectory: '$(Pipeline.Workspace)/s/helloworld/Infrastructure/Terraform'
inlineScript: |
# Define a unique state file key for this build
$STATE_FILE_KEY = "helloworld-$(EnvironmentName)-$(Build.BuildId).tfstate"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the state files going to accumulate forever? I want to show using the storage account but if these are going to be left around forever we should probably delete it as part of the teardown with a comment explaining why we stored it to begin with

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's correct, this is something that I wanted to check with you: state files and docker images will accumulate, so we can backlog a ticket to add some clean-up tasks for hello-world docker images and tfstate files.
Currently, there are 112 tags in hello-world ACR repo, but I think the manage identity will need more permissions to do the clean-up.

- checkout: self
path: s/helloworld

- task: TerraformInstaller@1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why install latest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To have the latest patches and features, but either way in provider.tf we are using this:
required_version = "~> 1.0"
The ~> symbol allows the minor version to be greater than 0, but keep the major version in 1.x to avoid any breaking changes with a major version change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants