diff --git a/aws-py-django-voting-app/__main__.py b/aws-py-django-voting-app/__main__.py index 82c361181..10c2fec5a 100644 --- a/aws-py-django-voting-app/__main__.py +++ b/aws-py-django-voting-app/__main__.py @@ -167,7 +167,7 @@ name="votes", opts=pulumi.ResourceOptions(provider=mysql_provider)) -# Creating a user which will be used to manage MySQL tables +# Creating a user which will be used to manage MySQL tables mysql_user = mysql.User("mysql-standard-user", user=sql_user_name, host="%", # "%" indicates that the connection is allowed to come from anywhere @@ -214,15 +214,22 @@ # Creating a Docker image from "./frontend/Dockerfile", which we will use # to upload our app -def get_registry_info(rid): - creds = aws.ecr.get_credentials(registry_id=rid) + +def get_registry_info(creds): decoded = base64.b64decode(creds.authorization_token).decode() parts = decoded.split(':') if len(parts) != 2: raise Exception("Invalid credentials") - return docker.ImageRegistry(creds.proxy_endpoint, parts[0], parts[1]) -app_registry = app_ecr_repo.registry_id.apply(get_registry_info) + username = parts[0] + password = parts[1] + return docker.ImageRegistry( + server=creds.proxy_endpoint, + username=username, + password=password) + +app_registry = aws.ecr.get_credentials_output(app_ecr_repo.registry_id) \ + .apply(get_registry_info) django_image = docker.Image("django-dockerimage", image_name=app_ecr_repo.repository_url, @@ -237,8 +244,8 @@ def get_registry_info(rid): name="django-log-group" ) -# Creating a task definition for the first Django instance. This task definition -# will migrate the database, create a site admin account, and will automatcially +# Creating a task definition for the first Django instance. This task definition +# will migrate the database, create a site admin account, and will automatcially # exit when it is finished. django_database_task_definition = aws.ecs.TaskDefinition("django-database-task-definition", family="django_database_task_definition-family", @@ -253,9 +260,9 @@ def get_registry_info(rid): django_secret_key, mysql_database.name, sql_admin_name, - sql_admin_password, + sql_admin_password, django_admin_name, - django_admin_password, + django_admin_password, mysql_rds_server.address, mysql_rds_server.port).apply(lambda args: json.dumps([{ "name": "django-container", @@ -282,7 +289,7 @@ def get_registry_info(rid): "options": { "awslogs-group": "django-log-group", "awslogs-region": "us-west-2", - "awslogs-stream-prefix": "djangoApp-database", + "awslogs-stream-prefix": "djangoApp-database", }, }, "command": ["/mysite/setupDatabase.sh"] @@ -323,7 +330,7 @@ def get_registry_info(rid): django_secret_key, mysql_database.name, sql_user_name, - sql_user_password, + sql_user_password, mysql_rds_server.address, mysql_rds_server.port).apply(lambda args: json.dumps([{ "name": "django-container", @@ -348,7 +355,7 @@ def get_registry_info(rid): "options": { "awslogs-group": "django-log-group", "awslogs-region": "us-west-2", - "awslogs-stream-prefix": "djangoApp-site", + "awslogs-stream-prefix": "djangoApp-site", }, }, }]))) diff --git a/azure-py-aks-helm/cluster.py b/azure-py-aks-helm/cluster.py index d27289ac6..3d2e029d6 100644 --- a/azure-py-aks-helm/cluster.py +++ b/azure-py-aks-helm/cluster.py @@ -65,12 +65,9 @@ }) -creds = pulumi.Output.all(resource_group.name, k8s_cluster.name).apply( - lambda args: - containerservice.list_managed_cluster_user_credentials( - resource_group_name=args[0], - resource_name=args[1])) - +creds = containerservice.list_managed_cluster_user_credentials_output( + resource_group_name=resource_group.name, + resource_name=k8s_cluster.name) kubeconfig = creds.kubeconfigs[0].value.apply( lambda enc: base64.b64decode(enc).decode()) diff --git a/azure-py-aks/__main__.py b/azure-py-aks/__main__.py index 0359740c3..376ac9126 100644 --- a/azure-py-aks/__main__.py +++ b/azure-py-aks/__main__.py @@ -65,11 +65,9 @@ "secret": ad_sp_password.value }) -creds = pulumi.Output.all(resource_group.name, managed_cluster.name).apply( - lambda args: - containerservice.list_managed_cluster_user_credentials( - resource_group_name=args[0], - resource_name=args[1])) +creds = containerservice.list_managed_cluster_user_credentials_output( + resource_group_name=resource_group.name, + resource_name=managed_cluster.name) # Export kubeconfig encoded = creds.kubeconfigs[0].value diff --git a/azure-py-appservice-docker/__main__.py b/azure-py-appservice-docker/__main__.py index e338a089d..1ab6652cf 100644 --- a/azure-py-appservice-docker/__main__.py +++ b/azure-py-appservice-docker/__main__.py @@ -58,9 +58,8 @@ ), admin_user_enabled=True) -credentials = pulumi.Output.all(resource_group.name, registry.name).apply( - lambda args: containerregistry.list_registry_credentials(resource_group_name=args[0], - registry_name=args[1])) +credentials = containerregistry.list_registry_credentials_output(resource_group_name=resource_group.name, + registry_name=registry.name) admin_username = credentials.username admin_password = credentials.passwords[0]["value"] diff --git a/azure-py-appservice/__main__.py b/azure-py-appservice/__main__.py index 73bc4c83d..242f2378f 100644 --- a/azure-py-appservice/__main__.py +++ b/azure-py-appservice/__main__.py @@ -43,31 +43,25 @@ type=storage.BlobType.BLOCK, source=asset.FileArchive("wwwroot")) - -def get_sas(args): - blob_sas = storage.list_storage_account_service_sas( - account_name=storage_account.name, - protocols=storage.HttpProtocol.HTTPS, - shared_access_start_time="2021-01-01", - shared_access_expiry_time="2030-01-01", - resource=storage.SignedResource.C, - resource_group_name=args[3], - permissions=storage.Permissions.R, - canonicalized_resource="/blob/" + args[0] + "/" + args[1], - content_type="application/json", - cache_control="max-age=5", - content_disposition="inline", - content_encoding="deflate", - ) - return f"https://{args[0]}.blob.core.windows.net/{args[1]}/{args[2]}?{blob_sas.service_sas_token}" - - -signed_blob_url = Output.all( - storage_account.name, - storage_container.name, - blob.name, - resource_group.name, -).apply(get_sas) +blob_sas = storage.list_storage_account_service_sas_output( + account_name=storage_account.name, + protocols=storage.HttpProtocol.HTTPS, + shared_access_start_time="2021-01-01", + shared_access_expiry_time="2030-01-01", + resource=storage.SignedResource.C, + resource_group_name=resource_group.name, + permissions=storage.Permissions.R, + canonicalized_resource=Output.concat("/blob/", storage_account.name, "/", storage_container.name), + content_type="application/json", + cache_control="max-age=5", + content_disposition="inline", + content_encoding="deflate") + +signed_blob_url = Output.concat( + "https://", storage_account.name, ".blob.core.windows.net/", + storage_container.name, "/", + blob.name, "?", + blob_sas.service_sas_token) app_insights = insights.Component( "appservice-ai", @@ -90,9 +84,12 @@ def get_sas(args): name="S0", )) -connection_string = Output.all(sql_server.name, database.name, username, pwd) \ - .apply(lambda - args: f"Server=tcp:{args[0]}.database.windows.net;initial catalog={args[1]};user ID={args[2]};password={args[3]};Min Pool Size=0;Max Pool Size=30;Persist Security Info=true;") +connection_string = Output.concat( + "Server=tcp:", sql_server.name, ".database.windows.net;initial ", + "catalog=", database.name, + ";user ID=", username, + ";password=", pwd, + ";Min Pool Size=0;Max Pool Size=30;Persist Security Info=true;") app = web.WebApp( "appservice-as", diff --git a/azure-py-cosmosdb-logicapp/__main__.py b/azure-py-cosmosdb-logicapp/__main__.py index b01483f74..bcadaf8ce 100644 --- a/azure-py-cosmosdb-logicapp/__main__.py +++ b/azure-py-cosmosdb-logicapp/__main__.py @@ -56,13 +56,16 @@ ) )) -account_keys = pulumi.Output.all(cosmosdb_account.name, resource_group.name).apply( - lambda arg: documentdb.list_database_account_keys(account_name=arg[0], resource_group_name=arg[1])) +account_keys = documentdb.list_database_account_keys_output( + account_name=cosmosdb_account.name, + resource_group_name=resource_group.name) client_config = pulumi.Output.from_input(authorization.get_client_config()) -api_id = pulumi.Output.all(client_config.subscription_id, resource_group.location).apply( - lambda arg: f"/subscriptions/{arg[0]}/providers/Microsoft.Web/locations/{arg[1]}/managedApis/documentdb") +api_id = pulumi.Output.concat( + "/subscriptions/", client_config.subscription_id, + "/providers/Microsoft.Web/locations/", resource_group.location, + "/managedApis/documentdb") # API Connection to be used in a Logic App connection = web.Connection( @@ -137,11 +140,12 @@ ), }) -callback_urls = pulumi.Output.all(resource_group.name, workflow.name).apply( - lambda arg: logic.list_workflow_trigger_callback_url( - resource_group_name=arg[0], - workflow_name=arg[1], - trigger_name="Receive_post")) + +callback_urls = logic.list_workflow_trigger_callback_url_output( + resource_group_name=resource_group.name, + workflow_name=workflow.name, + trigger_name="Receive_post") + # Export the HTTP endpoint pulumi.export("endpoint", callback_urls.value) diff --git a/azure-py-minecraft-server/__main__.py b/azure-py-minecraft-server/__main__.py index 2d28da29f..90b92fb59 100644 --- a/azure-py-minecraft-server/__main__.py +++ b/azure-py-minecraft-server/__main__.py @@ -108,11 +108,10 @@ def decode_key(key): ) # Get IP address as an output. -combined_output = Output.all(server.id, public_ip.name, resource_group.name) -public_ip_addr = combined_output.apply( - lambda lst: network.get_public_ip_address( - public_ip_address_name=lst[1], - resource_group_name=lst[2])) +public_ip_addr = server.id.apply(lambda _: + network.get_public_ip_address_output( + public_ip_address_name=public_ip.name, + resource_group_name=resource_group.name)) # Create connection object to server. conn = provisioners.ConnectionArgs( diff --git a/azure-py-webserver/__main__.py b/azure-py-webserver/__main__.py index 37443bafc..97816a562 100644 --- a/azure-py-webserver/__main__.py +++ b/azure-py-webserver/__main__.py @@ -76,9 +76,8 @@ ), )) -combined_output = Output.all(vm.id, public_ip.name, resource_group.name) -public_ip_addr = combined_output.apply( - lambda lst: network.get_public_ip_address( - public_ip_address_name=lst[1], - resource_group_name=lst[2])) +public_ip_addr = vm.id.apply(lambda _: network.get_public_ip_address_output( + public_ip_address_name=public_ip.name, + resource_group_name=resource_group.name)) + export("public_ip", public_ip_addr.ip_address) diff --git a/classic-azure-py-msi-keyvault-rbac/__main__.py b/classic-azure-py-msi-keyvault-rbac/__main__.py index d1ade416a..0582e654d 100644 --- a/classic-azure-py-msi-keyvault-rbac/__main__.py +++ b/classic-azure-py-msi-keyvault-rbac/__main__.py @@ -91,29 +91,24 @@ def createFirewallRules(arg): )] ) -def get_sas(args): - blob_sas = storage.get_account_blob_container_sas( - connection_string=args[1], - start="2020-01-01", - expiry="2030-01-01", - container_name=args[2], - permissions=storage.GetAccountBlobContainerSASPermissionsArgs( - read=True, - write=False, - delete=False, - list=False, - add=False, - create=False, - ) - ) - return f"https://{args[0]}.blob.core.windows.net/{args[2]}/{args[3]}{blob_sas.sas}" - -signed_blob_url = Output.all( - storage_account.name, - storage_account.primary_connection_string, - storage_account.name, - blob.name -).apply(get_sas) +blob_sas = storage.get_account_blob_container_sas_output( + connection_string=storage_account.primary_connection_string, + start="2020-01-01", + expiry="2030-01-01", + container_name=container_storage_account.name, + permissions=storage.GetAccountBlobContainerSASPermissionsArgs( + read=True, + write=False, + delete=False, + list=False, + add=False, + create=False)) + +signed_blob_url = Output.concat( + "https://", storage_account.name, ".blob.core.windows.net/", + storage_account.name, "/", + blob.name, + blob_sas.sas) secret = keyvault.Secret( "deployment-zip", @@ -172,5 +167,3 @@ def get_sas(args): export("endpoint", app.default_site_hostname.apply( lambda endpoint: "https://" + endpoint )) - - diff --git a/classic-azure-py-webserver-component/webserver.py b/classic-azure-py-webserver-component/webserver.py index 302229a88..25213afc0 100644 --- a/classic-azure-py-webserver-component/webserver.py +++ b/classic-azure-py-webserver-component/webserver.py @@ -79,13 +79,11 @@ def __init__(self, name: str, args: WebServerArgs, opts: ResourceOptions = None) opts=child_opts, ) - # The public IP address is not allocated until the VM is running, so we wait - # for that resource to create, and then lookup the IP address again to report - # its public IP. - combined_output = Output.all( - vm.id, public_ip.name, public_ip.resource_group_name - ) - self.public_ip_addr = combined_output.apply( - lambda lst: network.get_public_ip(name=lst[1], resource_group_name=lst[2]).ip_address - ) + # The public IP address is not allocated until the VM is + # running, so we wait for that resource to create, and then + # lookup the IP address again to report its public IP. + self.public_ip_addr = vm.id.apply(lambda _: network.get_public_ip_output( + name=public_ip.name, + resource_group_name=public_ip.resource_group_name).ip_address) + self.register_outputs({}) diff --git a/libvirt-py-vm/libvirt_host.py b/libvirt-py-vm/libvirt_host.py index 8e80c7001..8de6d66eb 100644 --- a/libvirt-py-vm/libvirt_host.py +++ b/libvirt-py-vm/libvirt_host.py @@ -66,12 +66,12 @@ def __init__(self, # Install KVM sudo apt update - sudo apt-get -y install qemu-kvm libvirt-bin + sudo apt-get -y install qemu-kvm libvirt-bin # hack to account for this bug: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1677398 # Work around: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1677398/comments/42 sudo sed -i '$ a security_driver = "none"' /etc/libvirt/qemu.conf sudo systemctl restart libvirt-bin - + """ vm = compute.VirtualMachine( @@ -111,17 +111,15 @@ def __init__(self, ), opts=ResourceOptions(parent=self)) - # There's some delay between when Azure says the VM is ready and + # There's some delay between when Azure says the VM is ready and # when the KVM/qemu service can start accepting connections. # So, wait a bit to allow the KVM server to become fully ready. # But only do the wait if the VM has been provisioned (i.e. not during a preview). vm.provisioning_state.apply(lambda state: time.sleep(90)) - combined_output = Output.all(public_ip.name, resource_group.name, vm.id) - public_ip_addr = combined_output.apply( - lambda lst: network.get_public_ip_address( - public_ip_address_name=lst[0], - resource_group_name=lst[1])) + public_ip_addr = vm.id.apply(lambda _: network.get_public_ip_address_output( + public_ip_address_name=public_ip.name, + resource_group_name=resource_group.name)) # Create/update the private key file for the SSH remote connection URI. def write_key_file(priv_key, key_file): @@ -137,12 +135,12 @@ def write_key_file(priv_key, key_file): # Build the connection URI that is returned for use by the libvirt provider. # See https://libvirt.org/uri.html#URI_remote for details on the remote URI options self.libvirt_remote_uri = Output.concat("qemu+ssh://",username,"@",public_ip_addr.ip_address,"/system?keyfile=./",key_file,"&socket=/var/run/libvirt/libvirt-sock&no_verify=1") - + # Return where the VM pool should be created. - # In this case, the "vm pool" is simply placed under the KVM host user's home folder - self.vm_pool_dir = f"/home/{username}/vms" + # In this case, the "vm pool" is simply placed under the KVM host user's home folder + self.vm_pool_dir = f"/home/{username}/vms" - # Other values for convenience to output useful information + # Other values for convenience to output useful information self.ip = public_ip_addr.ip_address self.username = username self.ssh_priv_key_file = key_file