Skip to main content

Visual Studio Code extensions

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, KCL, and Go schemas.

tip

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, Python language server, or Go 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, 3.12, or 3.13. Follow the Python extension documentation to learn how to install Python. up builds Python functions in a container, so your local Python installation only provides editor features.

Upbound uses Pydantic Python schemas. Follow the Pydantic Visual Studio Code guide to enable autocompletion and type checking.

To resolve imports from the generated models package, create a venv virtual environment in each function's directory and install the function into it:

cd functions/<function-name>
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
pip install -e ../../.up/python

The last command installs the generated models in editable mode, so your editor picks up models that up regenerates when you add dependencies or change XRDs. Run it again after each pip install -e ., which replaces the editable models with a copy. up ignores the .venv directory when it builds your function.

Follow the Python extension documentation to learn how to select the virtual environment in Visual Studio Code.

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 generate functions, open the code 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.