generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 50
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
HCE-339 feat multi project #454
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9c9f1e1
add optional project_id to provider config
bcmdarroch f84f849
use configured project as default if set
bcmdarroch 9cf1640
add warning to getProjectFromCredentials
bcmdarroch a0365ff
update provider project id default assignment to equal oldest existin…
JolisaBrownHashiCorp 846f349
update changelog
JolisaBrownHashiCorp 4bfacb5
update docs
JolisaBrownHashiCorp 04b9b50
Hce 343 hvn project (#460)
JolisaBrownHashiCorp 7ccb100
add project id (#469)
itsjaspermilan a09f8ad
HCE 790 Add project_id to AWS Transit Gateway Attachment Resource (#470)
itsjaspermilan 1858354
add project id (#472)
itsjaspermilan 6f14aea
HCE-792: Add Project ID to Consul Cluster Resource (#473)
itsjaspermilan 3079ac7
Add project ID to AWS network peering (#471)
JolisaBrownHashiCorp e8f1723
HCE-793: Add Project ID to Vault Cluster (#474)
itsjaspermilan de9af2f
HCE-794: Add project_id to Boundary Cluster Resource (#475)
itsjaspermilan bd9f9e8
add project_id to packer data sources (#476)
itsjaspermilan e415863
HCE-812: multi-project migration guide (#481)
bcmdarroch 08ef0d9
HCE-345: Allow Project ID on Terraform Import (#487)
itsjaspermilan 3a0e48f
Update resource manager method names
delores-hashicorp 118996b
FIX TGW resource ID split.
delores-hashicorp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:feature | ||
Enable multi-project at provider level. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
--- | ||
subcategory: "" | ||
page_title: "Multi-Project Migration Guide - HCP Provider" | ||
description: |- | ||
A guide to migrating HCP resources to multiple projects. | ||
--- | ||
|
||
# Multi-project Migration Guide | ||
|
||
HCP now supports multiple projects. You may migrate your HCP Terraform configuration in the following ways. | ||
|
||
-> **Note:** Resources cannot be moved to new projects. Changing a resource's project will force its recreation. Before creating additional projects, we recommend configuring the current sole project as the provider's default project to ensure no recreation occurs. | ||
|
||
## 1. Default to oldest project (no change required) | ||
|
||
The HVN in this example will be created in the sole existing project, or if there is more than one project, the oldest project. | ||
|
||
```terraform | ||
provider "hcp" {} | ||
|
||
resource "hcp_hvn" "test" { | ||
hvn_id = "test-hvn" | ||
cloud_provider = "aws" | ||
region = "us-west-2" | ||
} | ||
``` | ||
|
||
## 2. Configure a default project on provider | ||
|
||
The HVN in this example will be created in the project configured at the provider level. | ||
|
||
```terraform | ||
provider "hcp" { | ||
project_id = "f709ec73-55d4-46d8-897d-816ebba28778" | ||
} | ||
|
||
resource "hcp_hvn" "test" { | ||
hvn_id = "test-hvn" | ||
cloud_provider = "aws" | ||
region = "us-west-2" | ||
} | ||
``` | ||
|
||
## 3. Configure projects on resource | ||
|
||
The HVN will be created in its configured project, while the HCP Consul cluster will be created in its different configured project. | ||
Since no project is configured on the provider, the default project will be the oldest project. | ||
|
||
```terraform | ||
provider "hcp" {} | ||
|
||
resource "hcp_hvn" "test" { | ||
hvn_id = "test-hvn" | ||
project_id = "f709ec73-55d4-46d8-897d-816ebba28778" | ||
cloud_provider = "aws" | ||
region = "us-west-2" | ||
} | ||
|
||
resource "hcp_consul_cluster" "consul_cluster" { | ||
cluster_id = "test-cluster" | ||
hvn_id = hcp_hvn.test.hvn_id | ||
project_id = "0f8c263e-8eb4-4a7f-a0cc-7e476afb9fd2" | ||
tier = "development" | ||
} | ||
``` | ||
|
||
### Override provider project with resource project | ||
|
||
Projects may be set at both the resource and provider level. The resource-configured project is always preferred over the provider-configured project. | ||
|
||
```terraform | ||
provider "hcp" { | ||
project_id = "f709ec73-55d4-46d8-897d-816ebba28778" | ||
} | ||
|
||
# This HVN will be created in the project "0f8c263e-8eb4-4a7f-a0cc-7e476afb9fd2" | ||
resource "hcp_hvn" "test" { | ||
hvn_id = "test-hvn" | ||
project_id = "0f8c263e-8eb4-4a7f-a0cc-7e476afb9fd2" | ||
cloud_provider = "aws" | ||
region = "us-west-2" | ||
} | ||
``` | ||
|
||
## Imports | ||
|
||
If no project is configured at the provider level, imported resources must include their project ID to ensure uniqueness. | ||
|
||
```shell | ||
# terraform import {resource_type}.{resource_name} {project_id}:{hvn_id} | ||
|
||
$ terraform import hcp_hvn.test f709ec73-55d4-46d8-897d-816ebba28778:test-hvn | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I discussed with @glasner about setting the
project_id
at the resource v.s. the provider config level in the use case of using multiple projects for multiple resources.The general guidance from Jordan is to:
Use Provider Alias (docs here) to create aliases of providers with individual configurations (can have one alias per project). It would remove the need to assign projects to each resource, especially when there are multiple resources referencing different products (like HCP Packer and HCP Vault Secrets) to be created.
If there is only one HCP product resource with a limited resource count, like a few data sources referencing different HCP Vault Secret applications in different HCP projects, setting the project at the resource level is optimal.
Let me know if I missed anything in our conversation, @glasner .
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.
To clarify: this is not a blocker, but a suggested change, to follow the Provider’s config best practice.