Skip to content

Module 12 - #12

Open
CharlieCumber wants to merge 7 commits into
mainfrom
module-12
Open

Module 12#12
CharlieCumber wants to merge 7 commits into
mainfrom
module-12

Conversation

@CharlieCumber

Copy link
Copy Markdown
Owner

No description provided.

@BenRamchandani BenRamchandani left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey, the Terraform config looks good and I can see the app is working.

I'll accept this on Aptem, but please make the suggested changes around marking variables/outputs as sensitive before merging.

Comment thread main.tf
}

resource "azurerm_app_service" "main" {
name = "charlie-devops-to-do-terraform"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's good practice to prefix everything, that way you can tell what's terraformed and can have multiple instances of the infrastructure.

Comment thread README.md
# Deploying the application

The application is deployed with azure and is accessible at https://charlie-devops-to-do.azurewebsites.net/
The application is deployed with azure and is accessible at https://prod-charlie-devops-to-do.azurewebsites.net/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread outputs.tf
Comment on lines +1 to +3
output "cd_webhook" {
value = "https://${azurerm_app_service.main.site_credential[0].username}:${azurerm_app_service.main.site_credential[0].password}@${azurerm_app_service.main.name}.scm.azurewebsites.net/docker/hook"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should be marked as sensitive = true so Terraform doesn't print it out, it has your App Service's deployment password in.

https://app.travis-ci.com/github/CharlieCumber1/DevOps-Course-Starter-Module-3/builds/233145846#L2025

You can change the password in the Azure portal, go to the App Service -> Container settings (Classic) -> FTPS credentials -> Application scope and reset the password.

Comment thread remote-state.tf
}

resource "azurerm_storage_account" "tfstate" {
name = "tfstate${random_string.resource_code.result}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You don't normally manage Terraform's backend state with Terraform. It means you can't recreate everything with one terraform apply, and can't use workspaces for different environments.

If you delete this file you'll need to remove these objects from the state so Terraform doesn't destroy them, e.g. terraform state rm 'azurerm_storage_account.tfstate'.

Comment thread variables.tf
Comment on lines +15 to +21
variable "AUTH_CLIENT_SECRET" {
description = "GitHub client secret for authentication."
}

variable "SECRET_KEY" {
description = "The Azure secret key"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These should both be marked as sensitive = true so they don't get printed in terraform plan output.

(Also the SECRET_KEY is for signing Flask's session cookies, not really Azure related)

@JackMeadDev JackMeadDev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice work, I can see Travis is now managing your infrastructure as part of its pipeline now, and that your app is up and running in Azure. I've left some thoughts below, and particularly we should definitely add sensitive tags to some of your input/output variables, but I'm happy for you to merge once you've done so
Edit: Looks like this is basically a duplicate of Ben's - feel free to ignore 🙂

Comment thread README.md
# Deploying the application

The application is deployed with azure and is accessible at https://charlie-devops-to-do.azurewebsites.net/
The application is deployed with azure and is accessible at https://prod-charlie-devops-to-do.azurewebsites.net/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not sure if you changed your plan, but I was actually able to access it at:
http://charlie-devops-to-do-terraform.azurewebsites.net/

Comment thread outputs.tf
@@ -0,0 +1,7 @@
output "cd_webhook" {
value = "https://${azurerm_app_service.main.site_credential[0].username}:${azurerm_app_service.main.site_credential[0].password}@${azurerm_app_service.main.name}.scm.azurewebsites.net/docker/hook"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We should mark this output as sensitive since it contains a password - that way Terraform will avoid logging it unless explicitly told to

Comment thread remote-state.tf
@@ -0,0 +1,20 @@
resource "random_string" "resource_code" {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We wouldn't usually track the storage account for the terraform state in terraform - you can't safely create the account until there's somewhere to store state, and obviously you can't create the state until the storage account exists. If you now tried to rename one of these resources, causing a destroy/recreate, then we'd lose the existing state. Curious to know if you disagree and there is some clever workaround/solution for this

Comment thread variables.tf
}

variable "AUTH_CLIENT_SECRET" {
description = "GitHub client secret for authentication."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As with the outputs, we should mark any sensitive input variables as such to avoid them potentially being printed out in logging anywhere

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.

3 participants