-
Notifications
You must be signed in to change notification settings - Fork 946
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
Author a managed resource import/adopt tool #1243
Comments
|
I suspect this would fit well in https://github.com/crossplaneio/crossplane-cli, which powers the |
A note for the future implementer: you only need to fill the required fields of the CR correctly and leave the rest empty. Crossplane will fetch the empty fields from the provider because of the late-initialization. |
|
I'm increasingly thinking it might be more useful to build a tool that can create a Crossplane CR given a running external resource. This would help folks migrate from Terraform, but also help folks migrate any external resource, even those that were not managed via Terraform. |
|
Relates to crossplane/docs#287. |
|
Creating CRs based on given external resources is only half of the problem imho. An even harder thing would be to assure 1:1 configuration parity, including resource linking (such as assigning managed services to the right vpc/security group) that's represented in terraform code. This also ties in with the concept of generic resource references (#1770). |
|
@negz I see you've changed the title to omit explicit reference to Terraform - I assume this was in relation to your last comment
However I think that a generic import tool would better be tackled separately. Consider that terraform code:
Thus the task of importing resources specifically from terraform looks to me better defined and distinct from the task of writing a generic tool. |
|
@negz Here's another argument why using terraform as a source serves different scenarios: Consider a case where parts of infrastructure belong to different projects even though they are provisioned under the same provider account. On the terraform side, they live in separate git repos, but on the provider side, you don't see that grouping. For such case it's not useful to rely on a tool that identifies and imports all cloud resources as crossplane CRs. In order to complete terraform->crossplane migration, you'd still need to match individual CRs with respective repositories just as they were defined in terraform. |
|
In order to import a resource, the following information should be given at the bare minimum:
The provider-specific tool can query the API and get the required fields and then create a managed resource with retrieved information (that includes values of required fields). However, if the user already has the values for the required fields, then it won't need to make a One option is using terraform state as the information store; tool will read it to get the required fields and print bunch of managed resource YAMLs. However, it needs to be able to match terraform resource kinds & fields to Crossplane kinds & fields, which is not straightforward and easy to automate. IMO, it is not worth the effort. The other option is to write a tool that will call # kind corresponds to literal kind of the managed resource, which may not be same as what you see in console.
$ crossplane import gcp --kind CloudSQLInstance --external-name my_database
Fetching infromation from GCP...
my_database/cloudsqlinstance.gcp.crossplane.io createdThen additional tools can be built on top of that because it doesn't depend on another intermediary like TF state. For example, a tool that will list every instance of every service can use this tool to import those resources without having to go through terraform. |
|
@muvaf I think it would be nice if we can let user point to the GCP service and we import all the instances in crosspalne. For instance, if user wants to import all CloudSqlInstances, crossplane should be able to do that, it seems like most APIs have the If I interpreted the rest correctly, idea is to parse terraform config which was used to provision the resource to figure out the |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
@nalshamaajc I think using observe-only management policy can get you what you want. |
|
Related: #3999 |
What problem are you facing?
Many folks use Terraform to managed their infrastructure. Crossplane can 'adopt' existing infrastructure, including that originally provisioned by Terraform, by statically provisioning a Crossplane managed resource and setting its external name annotation (
crossplane.io/external-name) to the name of the existing resource. One challenge with this approach is that the statically provisioned managed resource's configuration must match that of the existing resource; if it does not Crossplane will immediately update the existing resource to match the configuration specified by Crossplane.How could Crossplane help solve your problem?
Crossplane could provide a tool that translated from a Terraform HCL configuration (or state file?) to the corresponding Crossplane managed resource. For example:
The text was updated successfully, but these errors were encountered: