-
Notifications
You must be signed in to change notification settings - Fork 12
Import Existing Resources #66
Description
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-providerIn 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.