Skip to content
This repository has been archived by the owner on Nov 25, 2021. It is now read-only.

Import Existing Resources #66

Open
kferrone opened this issue Jul 1, 2020 · 2 comments
Open

Import Existing Resources #66

kferrone opened this issue Jul 1, 2020 · 2 comments

Comments

@kferrone
Copy link

kferrone commented Jul 1, 2020

The Issue

The process of importing existing resources from a provider into a crossplane resource is quite tedious and a bit dangerous. The crossplane resource must match exactly all the properties to the existing resource from the provider. If the props don't exactly match; the resource will be modified to match what the crossplane resource says. If one were to accidentally omit a property then that property will be removed and/or set to its default instead of what it should be.

here are the docs on importing, which in my opinion are a little lite on the specifics: Crossplane Import Existing Resources

Suggested Solution

Would be nice to have the Crossplane CLI make the imported resource yaml for me.

I imagine a command like:
kubectl crossplane import aws vpc MyCoolVPC

The command would take a few different kinds of params like name, id, or ARN.
kubectl crossplane import aws vpc vpc-123abc456def

Then the generated output would be something like:

apiVersion: network.aws.crossplane.io/v1alpha3
kind: VPC
metadata:
  name: my-cool-vpc
  annotations:
    crossplane.io/external-name: vpc-someid
spec:
  cidrBlock: 10.100.0.0/16
  enableDnsHostNames: true
  enableDnsSupport: true
  reclaimPolicy: Retain
  tags:
    Name: MyCoolVPC
    "aws:cloudformation:logical-id": VPCA1B23C
    "aws:cloudformation:stack-id": "arn:aws:cloudformation:us-west-2:1234567:stack/MyStack/8f834j340"
    "aws:cloudformation:stack-name": MyStack
  providerRef:
    name: aws-provider

In the example above, if I were to forget to add the tags made by cloudformation, then the resource would get disassociated from the cloudformation stack and bad things would happen. Even worse, what if the cidrBlock was typed in wrong. . . Importing from the CLI would prevent a person from any dumb human mistakes.

@kferrone
Copy link
Author

kferrone commented Jul 1, 2020

So I just learned the tags that start with aws: are reserved for AWS internals and therefore Crossplane can safely ignore them.

@negz
Copy link
Member

negz commented Jul 2, 2020

Thanks for raising this @kferrone. This sounds very similar to our thinking in crossplane/crossplane#1093. I think this repository is the right place for the issue, so I'm going to close the older one and mark it as a duplicate. Future readers - please note the issue I'm about to roll into this one has some good context on how this might be built.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants