published on Monday, Aug 24, 2026 by Pulumi
published on Monday, Aug 24, 2026 by Pulumi
Provides a ESA Routine Code Deployment resource. It deploys one or two committed code versions of a routine to an environment, optionally splitting traffic between them for a canary (percentage) rollout.
For information about ESA Routine Code Deployment and how to use it, see What is Routine Code Deployment.
NOTE: Available since v1.287.0.
NOTE: A code deployment is a rollout event bound to an environment. The Alibaba Cloud ESA API provides no operation to withdraw a deployment; a deployed version can only be replaced by a new deployment. Destroying this resource only removes it from the Terraform state and does not roll back the deployed code.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "terraform-example";
const _default = new alicloud.esa.Routine("default", {
name: name,
code: "addEventListener('fetch', e => e.respondWith(new Response('hello')))",
codeDescription: "version 1",
});
const defaultRoutineCodeDeployment = new alicloud.esa.RoutineCodeDeployment("default", {
routineName: _default.name,
env: "staging",
strategy: "percentage",
codeVersions: [{
codeVersion: _default.latestCodeVersion,
percentage: 100,
}],
});
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
default = alicloud.esa.Routine("default",
name=name,
code="addEventListener('fetch', e => e.respondWith(new Response('hello')))",
code_description="version 1")
default_routine_code_deployment = alicloud.esa.RoutineCodeDeployment("default",
routine_name=default.name,
env="staging",
strategy="percentage",
code_versions=[{
"code_version": default.latest_code_version,
"percentage": 100,
}])
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/esa"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "terraform-example"
if param := cfg.Get("name"); param != "" {
name = param
}
_default, err := esa.NewRoutine(ctx, "default", &esa.RoutineArgs{
Name: pulumi.String(name),
Code: pulumi.String("addEventListener('fetch', e => e.respondWith(new Response('hello')))"),
CodeDescription: pulumi.String("version 1"),
})
if err != nil {
return err
}
_, err = esa.NewRoutineCodeDeployment(ctx, "default", &esa.RoutineCodeDeploymentArgs{
RoutineName: _default.Name,
Env: pulumi.String("staging"),
Strategy: pulumi.String("percentage"),
CodeVersions: esa.RoutineCodeDeploymentCodeVersionArray{
&esa.RoutineCodeDeploymentCodeVersionArgs{
CodeVersion: _default.LatestCodeVersion,
Percentage: pulumi.Int(100),
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "terraform-example";
var @default = new AliCloud.Esa.Routine("default", new()
{
Name = name,
Code = "addEventListener('fetch', e => e.respondWith(new Response('hello')))",
CodeDescription = "version 1",
});
var defaultRoutineCodeDeployment = new AliCloud.Esa.RoutineCodeDeployment("default", new()
{
RoutineName = @default.Name,
Env = "staging",
Strategy = "percentage",
CodeVersions = new[]
{
new AliCloud.Esa.Inputs.RoutineCodeDeploymentCodeVersionArgs
{
CodeVersion = @default.LatestCodeVersion,
Percentage = 100,
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.esa.Routine;
import com.pulumi.alicloud.esa.RoutineArgs;
import com.pulumi.alicloud.esa.RoutineCodeDeployment;
import com.pulumi.alicloud.esa.RoutineCodeDeploymentArgs;
import com.pulumi.alicloud.esa.inputs.RoutineCodeDeploymentCodeVersionArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var config = ctx.config();
final var name = config.get("name").orElse("terraform-example");
var default_ = new Routine("default", RoutineArgs.builder()
.name(name)
.code("addEventListener('fetch', e => e.respondWith(new Response('hello')))")
.codeDescription("version 1")
.build());
var defaultRoutineCodeDeployment = new RoutineCodeDeployment("defaultRoutineCodeDeployment", RoutineCodeDeploymentArgs.builder()
.routineName(default_.name())
.env("staging")
.strategy("percentage")
.codeVersions(RoutineCodeDeploymentCodeVersionArgs.builder()
.codeVersion(default_.latestCodeVersion())
.percentage(100)
.build())
.build());
}
}
configuration:
name:
type: string
default: terraform-example
resources:
default:
type: alicloud:esa:Routine
properties:
name: ${name}
code: addEventListener('fetch', e => e.respondWith(new Response('hello')))
codeDescription: version 1
defaultRoutineCodeDeployment:
type: alicloud:esa:RoutineCodeDeployment
name: default
properties:
routineName: ${default.name}
env: staging
strategy: percentage
codeVersions:
- codeVersion: ${default.latestCodeVersion}
percentage: 100
pulumi {
required_providers {
alicloud = {
source = "pulumi/alicloud"
}
}
}
resource "alicloud_esa_routine" "default" {
name = var.name
code = "addEventListener('fetch', e => e.respondWith(new Response('hello')))"
code_description = "version 1"
}
resource "alicloud_esa_routinecodedeployment" "default" {
routine_name = alicloud_esa_routine.default.name
env = "staging"
strategy = "percentage"
code_versions {
code_version = alicloud_esa_routine.default.latest_code_version
percentage = 100
}
}
variable "name" {
type = string
default = "terraform-example"
}
📚 Need more examples? VIEW MORE EXAMPLES
Create RoutineCodeDeployment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new RoutineCodeDeployment(name: string, args: RoutineCodeDeploymentArgs, opts?: CustomResourceOptions);@overload
def RoutineCodeDeployment(resource_name: str,
args: RoutineCodeDeploymentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def RoutineCodeDeployment(resource_name: str,
opts: Optional[ResourceOptions] = None,
code_versions: Optional[Sequence[RoutineCodeDeploymentCodeVersionArgs]] = None,
env: Optional[str] = None,
routine_name: Optional[str] = None,
strategy: Optional[str] = None)func NewRoutineCodeDeployment(ctx *Context, name string, args RoutineCodeDeploymentArgs, opts ...ResourceOption) (*RoutineCodeDeployment, error)public RoutineCodeDeployment(string name, RoutineCodeDeploymentArgs args, CustomResourceOptions? opts = null)
public RoutineCodeDeployment(String name, RoutineCodeDeploymentArgs args)
public RoutineCodeDeployment(String name, RoutineCodeDeploymentArgs args, CustomResourceOptions options)
type: alicloud:esa:RoutineCodeDeployment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "alicloud_esa_routine_code_deployment" "name" {
# resource properties
}Parameters
- name string
- The unique name of the resource.
- args RoutineCodeDeploymentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args RoutineCodeDeploymentArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args RoutineCodeDeploymentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RoutineCodeDeploymentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args RoutineCodeDeploymentArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var routineCodeDeploymentResource = new AliCloud.Esa.RoutineCodeDeployment("routineCodeDeploymentResource", new()
{
CodeVersions = new[]
{
new AliCloud.Esa.Inputs.RoutineCodeDeploymentCodeVersionArgs
{
CodeVersion = "string",
Percentage = 0,
},
},
Env = "string",
RoutineName = "string",
Strategy = "string",
});
example, err := esa.NewRoutineCodeDeployment(ctx, "routineCodeDeploymentResource", &esa.RoutineCodeDeploymentArgs{
CodeVersions: esa.RoutineCodeDeploymentCodeVersionArray{
&esa.RoutineCodeDeploymentCodeVersionArgs{
CodeVersion: pulumi.String("string"),
Percentage: pulumi.Int(0),
},
},
Env: pulumi.String("string"),
RoutineName: pulumi.String("string"),
Strategy: pulumi.String("string"),
})
resource "alicloud_esa_routine_code_deployment" "routineCodeDeploymentResource" {
lifecycle {
create_before_destroy = true
}
code_versions {
code_version = "string"
percentage = 0
}
env = "string"
routine_name = "string"
strategy = "string"
}
var routineCodeDeploymentResource = new RoutineCodeDeployment("routineCodeDeploymentResource", RoutineCodeDeploymentArgs.builder()
.codeVersions(RoutineCodeDeploymentCodeVersionArgs.builder()
.codeVersion("string")
.percentage(0)
.build())
.env("string")
.routineName("string")
.strategy("string")
.build());
routine_code_deployment_resource = alicloud.esa.RoutineCodeDeployment("routineCodeDeploymentResource",
code_versions=[{
"code_version": "string",
"percentage": 0,
}],
env="string",
routine_name="string",
strategy="string")
const routineCodeDeploymentResource = new alicloud.esa.RoutineCodeDeployment("routineCodeDeploymentResource", {
codeVersions: [{
codeVersion: "string",
percentage: 0,
}],
env: "string",
routineName: "string",
strategy: "string",
});
type: alicloud:esa:RoutineCodeDeployment
properties:
codeVersions:
- codeVersion: string
percentage: 0
env: string
routineName: string
strategy: string
RoutineCodeDeployment Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The RoutineCodeDeployment resource accepts the following input properties:
- Code
Versions List<Pulumi.Ali Cloud. Esa. Inputs. Routine Code Deployment Code Version> - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - Env string
- The target environment. Valid values:
staging,production. - Routine
Name string - The name of the routine to deploy.
- Strategy string
- The deployment strategy. Valid values:
percentage. Default value:percentage.
- Code
Versions []RoutineCode Deployment Code Version Args - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - Env string
- The target environment. Valid values:
staging,production. - Routine
Name string - The name of the routine to deploy.
- Strategy string
- The deployment strategy. Valid values:
percentage. Default value:percentage.
- code_
versions list(object) - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - env string
- The target environment. Valid values:
staging,production. - routine_
name string - The name of the routine to deploy.
- strategy string
- The deployment strategy. Valid values:
percentage. Default value:percentage.
- code
Versions List<RoutineCode Deployment Code Version> - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - env String
- The target environment. Valid values:
staging,production. - routine
Name String - The name of the routine to deploy.
- strategy String
- The deployment strategy. Valid values:
percentage. Default value:percentage.
- code
Versions RoutineCode Deployment Code Version[] - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - env string
- The target environment. Valid values:
staging,production. - routine
Name string - The name of the routine to deploy.
- strategy string
- The deployment strategy. Valid values:
percentage. Default value:percentage.
- code_
versions Sequence[RoutineCode Deployment Code Version Args] - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - env str
- The target environment. Valid values:
staging,production. - routine_
name str - The name of the routine to deploy.
- strategy str
- The deployment strategy. Valid values:
percentage. Default value:percentage.
- code
Versions List<Property Map> - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - env String
- The target environment. Valid values:
staging,production. - routine
Name String - The name of the routine to deploy.
- strategy String
- The deployment strategy. Valid values:
percentage. Default value:percentage.
Outputs
All input properties are implicitly available as output properties. Additionally, the RoutineCodeDeployment resource produces the following output properties:
- Deployment
Id string - The ID of the deployment record.
- Id string
- The provider-assigned unique ID for this managed resource.
- Deployment
Id string - The ID of the deployment record.
- Id string
- The provider-assigned unique ID for this managed resource.
- deployment_
id string - The ID of the deployment record.
- id string
- The provider-assigned unique ID for this managed resource.
- deployment
Id String - The ID of the deployment record.
- id String
- The provider-assigned unique ID for this managed resource.
- deployment
Id string - The ID of the deployment record.
- id string
- The provider-assigned unique ID for this managed resource.
- deployment_
id str - The ID of the deployment record.
- id str
- The provider-assigned unique ID for this managed resource.
- deployment
Id String - The ID of the deployment record.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing RoutineCodeDeployment Resource
Get an existing RoutineCodeDeployment resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: RoutineCodeDeploymentState, opts?: CustomResourceOptions): RoutineCodeDeployment@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
code_versions: Optional[Sequence[RoutineCodeDeploymentCodeVersionArgs]] = None,
deployment_id: Optional[str] = None,
env: Optional[str] = None,
routine_name: Optional[str] = None,
strategy: Optional[str] = None) -> RoutineCodeDeploymentfunc GetRoutineCodeDeployment(ctx *Context, name string, id IDInput, state *RoutineCodeDeploymentState, opts ...ResourceOption) (*RoutineCodeDeployment, error)public static RoutineCodeDeployment Get(string name, Input<string> id, RoutineCodeDeploymentState? state, CustomResourceOptions? opts = null)public static RoutineCodeDeployment get(String name, Output<String> id, RoutineCodeDeploymentState state, CustomResourceOptions options)resources: _: type: alicloud:esa:RoutineCodeDeployment get: id: ${id}import {
to = alicloud_esa_routine_code_deployment.example
id = "${id}"
}
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Code
Versions List<Pulumi.Ali Cloud. Esa. Inputs. Routine Code Deployment Code Version> - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - Deployment
Id string - The ID of the deployment record.
- Env string
- The target environment. Valid values:
staging,production. - Routine
Name string - The name of the routine to deploy.
- Strategy string
- The deployment strategy. Valid values:
percentage. Default value:percentage.
- Code
Versions []RoutineCode Deployment Code Version Args - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - Deployment
Id string - The ID of the deployment record.
- Env string
- The target environment. Valid values:
staging,production. - Routine
Name string - The name of the routine to deploy.
- Strategy string
- The deployment strategy. Valid values:
percentage. Default value:percentage.
- code_
versions list(object) - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - deployment_
id string - The ID of the deployment record.
- env string
- The target environment. Valid values:
staging,production. - routine_
name string - The name of the routine to deploy.
- strategy string
- The deployment strategy. Valid values:
percentage. Default value:percentage.
- code
Versions List<RoutineCode Deployment Code Version> - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - deployment
Id String - The ID of the deployment record.
- env String
- The target environment. Valid values:
staging,production. - routine
Name String - The name of the routine to deploy.
- strategy String
- The deployment strategy. Valid values:
percentage. Default value:percentage.
- code
Versions RoutineCode Deployment Code Version[] - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - deployment
Id string - The ID of the deployment record.
- env string
- The target environment. Valid values:
staging,production. - routine
Name string - The name of the routine to deploy.
- strategy string
- The deployment strategy. Valid values:
percentage. Default value:percentage.
- code_
versions Sequence[RoutineCode Deployment Code Version Args] - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - deployment_
id str - The ID of the deployment record.
- env str
- The target environment. Valid values:
staging,production. - routine_
name str - The name of the routine to deploy.
- strategy str
- The deployment strategy. Valid values:
percentage. Default value:percentage.
- code
Versions List<Property Map> - The list of code versions and their traffic percentages. At most two versions are supported, and the percentages must sum to 100. See
codeVersionsbelow. - deployment
Id String - The ID of the deployment record.
- env String
- The target environment. Valid values:
staging,production. - routine
Name String - The name of the routine to deploy.
- strategy String
- The deployment strategy. Valid values:
percentage. Default value:percentage.
Supporting Types
RoutineCodeDeploymentCodeVersion, RoutineCodeDeploymentCodeVersionArgs
- Code
Version string - The committed code version to deploy.
- Percentage int
- The traffic percentage of this code version. Valid values: 1 to 100.
- Code
Version string - The committed code version to deploy.
- Percentage int
- The traffic percentage of this code version. Valid values: 1 to 100.
- code_
version string - The committed code version to deploy.
- percentage number
- The traffic percentage of this code version. Valid values: 1 to 100.
- code
Version String - The committed code version to deploy.
- percentage Integer
- The traffic percentage of this code version. Valid values: 1 to 100.
- code
Version string - The committed code version to deploy.
- percentage number
- The traffic percentage of this code version. Valid values: 1 to 100.
- code_
version str - The committed code version to deploy.
- percentage int
- The traffic percentage of this code version. Valid values: 1 to 100.
- code
Version String - The committed code version to deploy.
- percentage Number
- The traffic percentage of this code version. Valid values: 1 to 100.
Import
ESA Routine Code Deployment can be imported using the id, e.g.
$ pulumi import alicloud:esa/routineCodeDeployment:RoutineCodeDeployment example <routine_name>:<env>
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloudTerraform Provider.
published on Monday, Aug 24, 2026 by Pulumi