-
Notifications
You must be signed in to change notification settings - Fork 1
Add Terraform backend when creating repository resources #911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: a9e6fdb The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report❌ Patch coverage is
❌ Your project status has failed because the head coverage (45.56%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #911 +/- ##
===========================================
- Coverage 67.85% 45.56% -22.30%
===========================================
Files 31 39 +8
Lines 840 1543 +703
Branches 146 184 +38
===========================================
+ Hits 570 703 +133
- Misses 258 826 +568
- Partials 12 14 +2
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds support for conditional Terraform backend configuration to the monorepo generator, allowing users to automatically configure state storage based on their selected cloud provider (AWS or Azure). It introduces user prompts for backend-specific details and dynamically injects the appropriate backend configuration into generated Terraform files.
- Adds new Handlebars template partials for AWS and Azure backend state configuration
- Extends user prompts to collect cloud provider-specific backend configuration details
- Implements dynamic partial loading logic to select the correct backend template based on user input
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
packages/monorepo-generator/templates/monorepo/infra/repository/providers.tf.hbs | Replaces TODO comment with dynamic backend state partial inclusion |
packages/monorepo-generator/templates/monorepo/infra/azure/partials/backend-state.tf.hbs | New Azure backend configuration template with azurerm backend |
packages/monorepo-generator/templates/monorepo/infra/aws/partials/backend-state.tf.hbs | New AWS backend configuration template with S3 backend |
packages/monorepo-generator/src/index.ts | Adds new prompts, backend partial selection logic, and updates action dependencies |
packages/monorepo-generator/README.md | Documents new template variables and updates formatting |
.changeset/swift-beers-deny.md | Changeset documentation for the feature addition |
{ | ||
default: "eu-south-1", | ||
message: "AWS region for tfstate:", | ||
name: "awsRegion", | ||
type: "input", | ||
when: (answers) => answers.csp === "aws", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: in my opinion this question should not be asked, we have to decide a region for our consumers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's difficult to put a default for region while keeping the tool agnostic from PagoPA habits.
Perhaps we could develop a CLI plugin for each business project we support to provide the right values to the user?
We already have a solution like this and it is actually implemented in part via a Terraform module, but the CLI scenario could expand it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about having all defaults in some config.yaml ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are they fetched?
message: "Azure resource group for tfstate:", | ||
name: "repoStateResourceGroupName", | ||
type: "input", | ||
when: (answers) => answers.csp === "azure", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: can't this be pre-filled following a convention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like ${prefix}-${envShort}-${locationShort}-terraform-rg-01
?
packages/monorepo-generator/templates/monorepo/infra/azure/partials/backend-state.tf.hbs
Show resolved
Hide resolved
4e0f475
to
3a9cd26
Compare
# Conflicts: # packages/monorepo-generator/README.md # packages/monorepo-generator/src/index.ts
3a9cd26
to
f7a02a6
Compare
f7a02a6
to
c6753ea
Compare
4e96ead
to
ae47d0b
Compare
This pull request introduces enhancements to the monorepo generator, specifically improving the Terraform infrastructure setup by dynamically configuring the backend state based on the selected cloud provider (CSP). It adds new prompt variables for both AWS and Azure backends, updates documentation, and implements the backend configuration in the generated Terraform files.
Closes CES-1278