def test_nested_config(self): 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 handler(event, context): base64_bytes = event['body'].encode('ascii') message_bytes = base64.b64decode(base64_bytes) message = message_bytes.decode('ascii') json_event = json.loads(message) bucket_name = json_event["bucket"] site_title = json_event["title"] site_body = json_event["body"] project_name = "website-builder" # We use a simple stack name here, but recommend using auto.fully_qualified_stack_name for maximum specificity. stack_name = auto.fully_qualified_stack_name("leezen", project_name, bucket_name) def pulumi_program(): create_static_website(bucket_name, site_title, site_body) # 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=LocalWorkspaceOptions(pulumi_home="/tmp/pulumi_home")) print("successfully initialized stack") # for inline programs, we must manage plugins ourselves print("installing plugins...") stack.workspace.install_plugin("aws", "v3.26.1") 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("updating stack...") up_res = stack.up(on_output=print) print( f"update summary: \n{json.dumps(up_res.summary.resource_changes, indent=4)}" ) print(f"website url: {up_res.outputs['website_url'].value}") return { 'statusCode': 200, 'body': json.dumps({'url': up_res.outputs['website_url'].value}), }