Official Upbound providers include schemas that you can leverage to enhance your Upbound development experience when authoring compositions. In Visual Studio Code, your Upbound project gets:
- Inline schema information
- Linting
- Autocompletion
Upbound supports Python and KCL schemas.
This documentation focuses on Visual Studio code, but other popular editors also support Python and KCL schemas, linting, and autocompletion.
Refer to the KCL language server or Python language server documentation to learn how to configure support for your preferred editor.
Installation
To install the Python extension, search for Python in your extensions search bar or go to the Marketplace in Visual Studio Code.
Crossplane functions require Python 3.11 or newer. Follow the Python extension documentation to learn how to install Python.
Upbound uses Pydantic Python schemas. Follow the Pydantic Visual Studio Code guide to enable autocompletion and type checking.
venv
virtual environment for each function to isolate its dependencies.
Follow the Python extension documentation
to learn how to create and select a virtual environment.Usage
After you install the extensions, you must use an official Upbound provider that includes bundled schemas.
In your project upbound.yaml
file, specify the provider and the latest version:
apiVersion: meta.dev.upbound.io/v1alpha1
kind: Project
spec:
dependsOn:
- provider: xpkg.upbound.io/upbound/provider-aws
version: v0.13.0
Once configured, you can open Python or KCL files in Visual Studio Code and start composing your resources.
Features
With the extensions and compatible Upbound provider, the following features are available:
Inline schema information
View descriptions, property types, and other schema details directly in your code editor window as you work with composed managed resources (MRs).
vpc = v1beta1.VPC(
apiVersion="ec2.aws.upbound.io/v1beta1",
kind="VPC",
spec=v1beta1.Spec(
forProvider=v1beta1.ForProvider(
region="us-west-2", # Hover to see description and type.
),
),
)
Linting
Real-time linting ensures:
- Property types are matched
- Managed resource required fields are populated
vpc = v1beta1.VPC(
apiVersion="ec2.aws.upbound.io/v1beta1",
kind="VPC",
spec=v1beta1.Spec(
forProvider=v1beta1.ForProvider(
cidrBlock=10, # Warning: Argument of type "Literal[10]" cannot be assigned to parameter "cidrBlock" of type "str | None"
# Warning: Argument missing for parameter "region"
),
),
)
Auto-completion
As you type, the extension suggests valid properties and values for managed resources.
vpc = v1beta1.VPC(
apiVersion="ec2.aws.upbound.io/v1beta1",
kind="VPC",
spec=v1beta1.Spec(
forProvider=v1beta1.ForProvider(
region="us-west-2",
ci # Auto-complete suggests: cidrBlock, cidrBlockAssociations, etc.
),
),
)
Auto-generate composed resources
Scaffold a new managed resource by using the auto-generate feature.
vpc = v1beta1.V # Auto-complete suggests VPC
Resource references
Navigate between related resources in your composition.
vpc = vpcv1beta1.VPC(**req.observed.resources["vpc"].resource)
subnet = subnetv1beta1.Subnet(
apiVersion="ec2.aws.upbound.io/v1beta1",
kind="Subnet",
spec=subnetv1beta1.Spec(
forProvider=subnetv1beta1.ForProvider(
region=vpc.spec.forProvider.region, # Ctrl+Click (Cmd+Click on Mac) to navigate to the VPC definition
vpcId=vpc.status.atProvider.arn,
),
),
)
Troubleshooting
If you’re not seeing the enhanced features:
- Ensure you’re using an official Upbound provider with bundled schemas.
- Check that the provider version in your
upbound.yaml
file matches the installed provider version. - Reload your Visual Studio Code window or restart Visual Studio Code.