mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
feat(pulumi): add manual method for importing components and their children
This commit is contained in:
@@ -1216,12 +1216,11 @@ The two approaches work in slightly different ways, and are suited to slightly d
|
|||||||
|
|
||||||
### Import components and their children
|
### Import components and their children
|
||||||
|
|
||||||
Create an import file for the resources that would be created, then import them using `pulumi import --file
|
The best and usually easier solution is to create an import file for the resources that would be created, then import
|
||||||
'import.json'`.
|
them in block using `pulumi import --file 'import.json'`.<br/>
|
||||||
|
Simplify the process by leveraging the `--import-file` option of the [`preview`][pulumi preview] command.
|
||||||
|
|
||||||
Simplify the process by leveraging the [`preview`][pulumi preview] command.
|
<details style='padding: 0 0 1rem 1rem'>
|
||||||
|
|
||||||
<details style="padding-left: 1em">
|
|
||||||
|
|
||||||
1. Write some code that would create the components:
|
1. Write some code that would create the components:
|
||||||
|
|
||||||
@@ -1307,6 +1306,47 @@ Simplify the process by leveraging the [`preview`][pulumi preview] command.
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
A manual alternative is to create the parent component, then import each child in the order they would be created by
|
||||||
|
using `pulumi import --parent …`.
|
||||||
|
|
||||||
|
<details style='padding: 0 0 1rem 1rem'>
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ pulumi preview
|
||||||
|
Previewing update (dev):
|
||||||
|
Type Name Plan Info
|
||||||
|
pulumi:pulumi:Stack someProj-dev 1 message
|
||||||
|
+ └─ someOrg:StandardSnowflakeServiceAccount n8n create
|
||||||
|
+ └─ snowflake:index:ServiceUser n8n create
|
||||||
|
+ └─ snowflake:index:UserProgrammaticAccessToken n8n create
|
||||||
|
|
||||||
|
Resources:
|
||||||
|
+ 3 to create
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Create only the component resource:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pulumi up --suppress-outputs --target 'urn:pulumi:dev::someProj::someOrg:SnowflakeServiceAccount::n8n'
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Import the component's direct children:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pulumi import 'snowflake:index/serviceUser:ServiceUser' 'n8n' 'N8N' \
|
||||||
|
--parent 'urn:pulumi:dev::someProj::someOrg:SnowflakeServiceAccount::n8n'
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Import children of lower order:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pulumi import 'snowflake:index/userProgrammaticAccessToken:UserProgrammaticAccessToken' \
|
||||||
|
'n8n' 'N8N_SERVICE_USER|N8N_SERVICE_PAT' \
|
||||||
|
--parent 'urn:pulumi:dev::someProj::someOrg:SnowflakeServiceAccount$snowflake:index/serviceUser:ServiceUser::n8n'
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
### A project with the same name already exists
|
### A project with the same name already exists
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ pulumi state unprotect 'urn:pulumi:dev::custom-images::aws:imagebuilder/infrastr
|
|||||||
pulumi state delete 'urn:pulumi:dev::custom-images::aws:imagebuilder/infrastructureConfiguration:InfrastructureConfiguration::server-baseline'
|
pulumi state delete 'urn:pulumi:dev::custom-images::aws:imagebuilder/infrastructureConfiguration:InfrastructureConfiguration::server-baseline'
|
||||||
pulumi state rename -y 'urn:pulumi:dev::custom-images::aws:imagebuilder/imageRecipe:ImageRecipe::baselineServerImage-1.0.8' 'serverBaseline-1.0.8'
|
pulumi state rename -y 'urn:pulumi:dev::custom-images::aws:imagebuilder/imageRecipe:ImageRecipe::baselineServerImage-1.0.8' 'serverBaseline-1.0.8'
|
||||||
|
|
||||||
|
pulumi state edit
|
||||||
|
EDITOR='vim' pulumi state edit
|
||||||
|
|
||||||
find '.' -type f -name 'Pulumi.yaml' -not -path "*/node_modules/*" -print -exec yq '.backend.url' {} '+'
|
find '.' -type f -name 'Pulumi.yaml' -not -path "*/node_modules/*" -print -exec yq '.backend.url' {} '+'
|
||||||
|
|
||||||
find '.' -type f -name 'Pulumi.yaml' -not -path "*/node_modules/*" -exec dirname {} + | xargs -pn '1' pulumi install --cwd
|
find '.' -type f -name 'Pulumi.yaml' -not -path "*/node_modules/*" -exec dirname {} + | xargs -pn '1' pulumi install --cwd
|
||||||
|
|||||||
Reference in New Issue
Block a user