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.
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
- Python
- KCL
- Go
- Go Templating
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.
Use a 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.
To install the KCL extension, search for KCL in your extensions search bar in Visual Studio Code or go to the Marketplace.
To install the Go extension, search for Go in your extensions search bar in Visual Studio Code or go to the Marketplace.
When editing Go Templating functions, use The YAML extension. To install it, search for YAML in your extensions search bar in Visual Studio Code or go to the Marketplace.
Go Templating functions generated with up function generate
contain modelines
that instruct Visual Studio Code to use the YAML extension when editing
them. This requires the
Modelines
extension.
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).
- Python
- KCL
- Go
- Go Templating
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.
),
),
)
vpc = {
apiVersion: "ec2.aws.upbound.io/v1beta1"
kind: "VPC"
spec.forProvider: {
cidrBlock: "10.0.0.0/16" # Hover to see description and type
enableDnsHostnames: True # Hover to see description and type
}
}
vpc := &v1beta1.VPC{
APIVersion: ptr.To("ec2.aws.upbound.io/v1beta1"),
Kind: ptr.To("VPC"),
Spec: &v1beta1.VPCSpec{
ForProvider: &v1beta1.VPCSpecForProvider{
CidrBlock: ptr.To("10.0.0.0/16"), / Hover to see description and type
EnableDNSHostnames: ptr.To(true), / Hover to see description and type
},
},
}
---
apiVersion: ec2.aws.upbound.io/v1beta1
kind: VPC
spec:
forProvider:
cidrBlock: "10.0.0.0/16" / Hover to see description and type
enableDNSHostnames: true / Hover to see description and type
Linting
Real-time linting ensures:
- Property types are matched
- Managed resource required fields are populated
- Python
- KCL
- Go
- Go Templating
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"
),
),
)
vpc = {
apiVersion: "ec2.aws.upbound.io/v1beta1"
kind: "VPC"
spec.forProvider: {
cidrBlock: 10 # Error: Expected string, got integer
# Error: Missing required field 'region'
}
}
vpc := &v1beta1.VPC{
APIVersion: ptr.To("ec2.aws.upbound.io/v1beta1"),
Kind: ptr.To("VPC"),
Spec: &v1beta1.VPCSpec{
ForProvider: &v1beta1.VPCSpecForProvider{
CidrBlock: 10, / Error: cannot use 10 (untyped int constant) as *string value in struct literal
},
},
}
---
apiVersion: ec2.aws.upbound.io/v1beta1
kind: VPC
spec:
forProvider: / Missing property "region"
cidrBlock: 10 / Incorrect type: Expected "string"
Auto-completion
As you type, the extension suggests valid properties and values for managed resources.
- Python
- KCL
- Go
- Go Templating
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.
),
),
)
vpc = {
apiVersion: "ec2.aws.upbound.io/v1beta1"
kind: "VPC"
spec.forProvider: {
ci # Auto-complete suggests: cidrBlock, cidrBlockAssociations, etc.
}
}
vpc := &v1beta1.VPC{
APIVersion: ptr.To("ec2.aws.upbound.io/v1beta1"),
Kind: ptr.To("VPC"),
Spec: &v1beta1.VPCSpec{
ForProvider: &v1beta1.VPCSpecForProvider{
Ci / Auto-complete suggests: CidrBlock, AssignGeneratedCidrBlock, Ipv6CidrBlock, etc.
},
},
}
---
apiVersion: ec2.aws.upbound.io/v1beta1
kind: VPC
spec:
forProvider:
ci / Auto-complete suggests: cidr, cidrBlock, etc.
Auto-generate composed resources
Scaffold a new managed resource by using the auto-generate feature.
- Python
- KCL
- Go
- Go Templating
vpc = v1beta1.V # Auto-complete suggests VPC
Start typing: vpc = {kind: "V"}
Select "VPC" from the autocomplete suggestions
The extension generates:
vpc = {
apiVersion: "ec2.aws.upbound.io/v1beta1"
kind: "VPC"
spec.forProvider: {
cidrBlock: ""
region: ""
}
}
vpc := &v1beta1.V / Auto-complete suggests VPC etc.
---
apiVersion: # Auto-complete suggests ec2.aws.upbound.io/v1beta1 etc.
kind: V # Auto-complete suggests VPC etc.
spec:
# Auto-complete generates the required fields:
forProvider:
region:
Resource references
Navigate between related resources in your composition.
- Python
- KCL
- Go
- Go Templating
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,
),
),
)
subnet = {
apiVersion: "ec2.aws.upbound.io/v1beta1"
kind: "Subnet"
spec.forProvider: {
vpcIdRef: {
name: "my-vpc" # Ctrl+Click (Cmd+Click on Mac) to navigate to the VPC definition
}
}
}
observedComposed, _ := request.GetObservedComposedResources(req)
observedVPC := observedComposed["vpc"]
observedVPCARN, _ := observedVPC.Resource.GetString("status.atProvider.arn")
subnet := &v1beta1.Subnet{
APIVersion: ptr.To("ec2.aws.upbound.io/v1beta1"),
Kind: ptr.To("Subnet"),
Spec: &v1beta1.SubnetSpec{
ForProvider: &v1beta1.SubnetSpecForProvider{
VpcID: &observedVPCARN, / Ctrl+Click (Cmd+Click on Mac) to navigate to the observedVPCARN definition
},
},
}
Navigating to references isn't supported in Go Templating files.
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.