feat: add import task to pulumi stacks
Some checks failed
ZeroDownTime/CloudBender/pipeline/head There was a failure building this commit
Some checks failed
ZeroDownTime/CloudBender/pipeline/head There was a failure building this commit
This commit is contained in:
parent
9a25dc34bb
commit
24c0346864
@ -212,6 +212,21 @@ def execute(cb, stack_name, function, args):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@click.command('import')
|
||||||
|
@click.argument("stack_name")
|
||||||
|
@click.argument("pulumi_state_file")
|
||||||
|
@click.pass_obj
|
||||||
|
def _import(cb, stack_name, pulumi_state_file):
|
||||||
|
"""Imports a Pulumi state file as stack"""
|
||||||
|
stacks = _find_stacks(cb, [stack_name])
|
||||||
|
|
||||||
|
for s in stacks:
|
||||||
|
if s.mode == "pulumi":
|
||||||
|
s._import(pulumi_state_file)
|
||||||
|
else:
|
||||||
|
logger.info("{} uses Cloudformation, export skipped.".format(s.stackname))
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.argument("stack_name")
|
@click.argument("stack_name")
|
||||||
@click.option(
|
@click.option(
|
||||||
@ -482,6 +497,7 @@ cli.add_command(refresh)
|
|||||||
cli.add_command(preview)
|
cli.add_command(preview)
|
||||||
cli.add_command(set_config)
|
cli.add_command(set_config)
|
||||||
cli.add_command(get_config)
|
cli.add_command(get_config)
|
||||||
|
cli.add_command(_import)
|
||||||
cli.add_command(export)
|
cli.add_command(export)
|
||||||
cli.add_command(assimilate)
|
cli.add_command(assimilate)
|
||||||
cli.add_command(execute)
|
cli.add_command(execute)
|
||||||
|
@ -1024,6 +1024,19 @@ class Stack(object):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pulumi_ws
|
||||||
|
def _import(self, pulumi_state_file):
|
||||||
|
"""Imports a Pulumi stack"""
|
||||||
|
|
||||||
|
pulumi_stack = self._get_pulumi_stack()
|
||||||
|
|
||||||
|
with open(pulumi_state_file, "r") as file:
|
||||||
|
state = json.loads(file.read())
|
||||||
|
deployment = pulumi.automation.Deployment(version=3, deployment=state)
|
||||||
|
pulumi_stack.import_stack(deployment)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
@pulumi_ws
|
@pulumi_ws
|
||||||
def set_config(self, key, value, secret):
|
def set_config(self, key, value, secret):
|
||||||
"""Set a config or secret"""
|
"""Set a config or secret"""
|
||||||
|
Loading…
Reference in New Issue
Block a user