def test_nested_config(self): if get_test_org() != "pulumi-test": return stack_name = fully_qualified_stack_name("pulumi-test", "nested_config", "dev") project_dir = test_path("data", "nested_config") stack = create_or_select_stack(stack_name, work_dir=project_dir) all_config = stack.get_all_config() outer_val = all_config["nested_config:outer"] self.assertTrue(outer_val.secret) self.assertEqual( outer_val.value, "{\"inner\":\"my_secret\",\"other\":\"something_else\"}") list_val = all_config["nested_config:myList"] self.assertFalse(list_val.secret) self.assertEqual(list_val.value, "[\"one\",\"two\",\"three\"]") outer = stack.get_config("outer") self.assertTrue(outer.secret) self.assertEqual( outer_val.value, "{\"inner\":\"my_secret\",\"other\":\"something_else\"}") arr = stack.get_config("myList") self.assertFalse(arr.secret) self.assertEqual(arr.value, "[\"one\",\"two\",\"three\"]")
def setUpClass(cls) -> None: cls.STACK_NAME = 'staging' cls.REGION_NAME = 'eu-north-1' cls.WORK_DIR = os.path.join(os.path.dirname(__file__)) cls.FILE_NAME = 'bucket.txt' cls.stack = auto.create_or_select_stack(stack_name=cls.STACK_NAME, work_dir=cls.WORK_DIR) cls.stack.set_config("aws:region", auto.ConfigValue(value=cls.REGION_NAME)) cls.stack.up(on_output=print) cls.outputs = cls.stack.outputs() cls.s3 = boto3.resource('s3')
secrets_provider = "awskms://aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee?region=us-west-2" kms_env = os.environ.get("KMS_KEY") if kms_env: secrets_provider = f"awskms://{kms_env}?region={os.environ.get('AWS_REGION')}" if secrets_provider == "awskms://aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee?region=us-west-2": raise Exception("Please provide an actual KMS key for secrets_provider") stack_settings=auto.StackSettings( secrets_provider=secrets_provider) # create or select a stack matching the specified name and project. # this will set up a workspace with everything necessary to run our inline program (pulumi_program) stack = auto.create_or_select_stack(stack_name=stack_name, project_name=project_name, program=pulumi_program, opts=auto.LocalWorkspaceOptions(project_settings=project_settings, secrets_provider=secrets_provider, stack_settings={"dev": stack_settings})) print("successfully initialized stack") # for inline programs, we must manage plugins ourselves print("installing plugins...") stack.workspace.install_plugin("aws", "v4.0.0") print("plugins installed") # set stack configuration specifying the AWS region to deploy print("setting up config") stack.set_config("aws:region", auto.ConfigValue(value="us-west-2")) print("config set")
import os from pulumi import automation as auto # To destroy our program, we can run python main.py destroy destroy = False args = sys.argv[1:] if len(args) > 0: if args[0] == "destroy": destroy = True stack_name = "dev" work_dir = os.path.join(os.path.dirname(__file__), "..", "fargate") # Create our stack using a local program in the ../fargate directory stack = auto.create_or_select_stack(stack_name="dev", work_dir=work_dir) print("successfully initialized stack") print("setting up config") stack.set_config("aws:region", auto.ConfigValue(value="us-west-2")) print("config set") print("refreshing stack") stack.refresh(on_output=print) print("refresh complete") if destroy: print("destroying stack...") stack.destroy(on_output=print) print("stack destroy complete") sys.exit()
# To destroy our program, we can run python main.py destroy destroy = False args = sys.argv[1:] if len(args) > 0: if args[0] == "destroy": destroy = True project_name = "inline_s3_project" # We use a simple stack name here, but recommend using auto.fully_qualified_stack_name for maximum specificity. stack_name = "dev" # stack_name = auto.fully_qualified_stack_name("myOrgOrUser", project_name, stack_name) # create or select a stack matching the specified name and project. # this will set up a workspace with everything necessary to run our inline program (pulumi_program) stack = auto.create_or_select_stack(stack_name=stack_name, project_name=project_name, program=pulumi_program) print("successfully initialized stack") # for inline programs, we must manage plugins ourselves print("installing plugins...") stack.workspace.install_plugin("aws", "v4.0.0") print("plugins installed") # set stack configuration specifying the AWS region to deploy print("setting up config") stack.set_config("aws:region", auto.ConfigValue(value="us-west-2")) print("config set") print("refreshing stack...")