Skip to content

Conversation

@lechnerc77
Copy link
Collaborator

Purpose

Does this introduce a breaking change?

[ ] Yes
[X] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[X] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Test the code
Open the Terraform Workspace
Execute azd up

Alternative:

Open the Terraform Workspace
Execute azd up

What to Check

Verify that the following are valid

  • The Infrastructure and the app are deployed to Azure

Other Information

closes #27

@lechnerc77 lechnerc77 added the enhancement New feature or request label Jan 21, 2023
@lechnerc77 lechnerc77 added this to the vNext 2.0 milestone Jan 21, 2023
@lechnerc77 lechnerc77 self-assigned this Jan 21, 2023
@lechnerc77 lechnerc77 marked this pull request as ready for review January 22, 2023 16:13
@lechnerc77
Copy link
Collaborator Author

In case of successful review, please do a squash&merge as the commit history has no value for the provided content

1. via template deployment and VS Code extension. This approach allows an quick deployment to Azure but does not necessarily reflect the best practices. You find more information on this option [here](documentation/DEPLOYMENT-VSCODE.md).
2. via [Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview) using `azd up`. This approach enables a quick and easy deployment and already contains best practices. It serves as a perfect starting point for a production grade setup. You find more information on this option [here](documentation/DEPLOYMENT-AZD.md).

> **Note** - If you choose to deploy to Azure via `azd` we provide two options to define the infrastructure as code, namely `Bicep` and `Terraform`. To make your life easier we provide two distinct [workspaces](https://code.visualstudio.com/docs/editor/workspaces#_multiroot-workspaces) for that to show you the relevant files and folders. If you want to go for `Bicep` you can open the workspace `workspaces/azd-bicep.code-workspace`, for Terraform go for the workspace `workspaces/azd-terraform.code-workspace`.
Copy link
Contributor

@MartinPankraz MartinPankraz Jan 23, 2023

Choose a reason for hiding this comment

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

Can we make the bicep workspace flavor default somehow? Would make things easier on first run with gh codespaces and vsc.

Seems like no easy way present at the moment: microsoft/vscode#161414

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I checked the documentation and did not find a way to define one workspace as default, neither via the workspace files nor via a vscode configuration we could attach.


## Mind the differences

The Terraform-based setup in the `azd` was introduced a later than the òne using Bicep. Due to that and due to the differences between them, some things work differently. Here are two things that we think are worth to mention.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo the "one"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed with commit c59ed5b


Our setup follows those defaults and there no explicit configuration is necessary.

## Infrastructure as Code - alternatives
Copy link
Contributor

Choose a reason for hiding this comment

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

"alternatives" in the titel sounds as if there is an additional default path. How about dropping it? And maybe a sentence on bicep being default for azd.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed with commit c59ed5b

@MartinPankraz
Copy link
Contributor

add alwaysOn: false to bicep config too: https://azure.github.io/PSRule.Rules.Azure/rules/Azure.AppService.AlwaysOn/

@MartinPankraz
Copy link
Contributor

@lechnerc77 azure cli dependency for terraform requires us to bring it back in after azd dropped it.

image

Copy link
Contributor

@MartinPankraz MartinPankraz left a comment

Choose a reason for hiding this comment

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

azure cli dependency for terraform deployment showed up while testing from gh codespace. Likely present in your local environment?

@MartinPankraz
Copy link
Contributor

When adding azure cli to the gh codespace manually and re-iterating "azd up" leads to login prompt for azure cli as well as challenge with interactive login:
image

@lechnerc77
Copy link
Collaborator Author

@lechnerc77
Copy link
Collaborator Author

Added a discussion in the Azure Developer CLI repo to check if we need additional config for Terraform login flow:Azure/azure-dev#1448 (comment)

@lechnerc77
Copy link
Collaborator Author

Enhanced the terraform instructions wrt to Azure CLI login flow in commit <Fixed with commit c59ed5b>

@MartinPankraz
Copy link
Contributor

Do we still need the terraform feature in the default dev container, when the template is anticipated to make the switch?

image

@MartinPankraz
Copy link
Contributor

MartinPankraz commented Jan 30, 2023

Moved devcontainer.json.azcli and executed 'azd config set auth.useAzCliAuth true' but still having login issues with azd login and az login likewise.

@lechnerc77
Copy link
Collaborator Author

Do we still need the terraform feature in the default dev container, when the template is anticipated to make the switch?

image

You are right, fixed this with commit 73d0301

@lechnerc77
Copy link
Collaborator Author

lechnerc77 commented Feb 4, 2023

Additional info: using az login in Codespaces causes issues (not an issue with azd but with login flow of Azure CLI). See these issues:

@MartinPankraz Can you verify that the workaround with exchanging the localhost redirect works?

@lechnerc77
Copy link
Collaborator Author

Added health endpoint configuration with commit 08f039b

Fixes issue #34 for Terraform as IaC provider

@lechnerc77
Copy link
Collaborator Author

lechnerc77 commented Feb 5, 2023

As some changes require a local modified copy of the azd core modules, I opened PRs that would sync the change to the azd core templates:

If accepted and merged, we can remove our local copy of the modules.

@lechnerc77
Copy link
Collaborator Author

@MartinPankraz : As discussed I added a disclaimer for the usage of codespaces in combination with the Terraform provider for Azure.

Copy link
Contributor

@MartinPankraz MartinPankraz left a comment

Choose a reason for hiding this comment

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

approved

@MartinPankraz MartinPankraz merged commit dd253ee into Azure-Samples:main Feb 10, 2023
@lechnerc77 lechnerc77 deleted the feat/iac-via-terraform branch February 10, 2023 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add Terraform as IaC option

2 participants