1. Packages
  2. Packages
  3. Defang Providers
  4. API Docs
  5. Service
Viewing docs for Defang AWS v2.4.1
published on Saturday, Jul 11, 2026 by Defang
defang-aws logo
Viewing docs for Defang AWS v2.4.1
published on Saturday, Jul 11, 2026 by Defang

    Create Service Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Service(name: string, args: ServiceArgs, opts?: ComponentResourceOptions);
    @overload
    def Service(resource_name: str,
                args: ServiceArgs,
                opts: Optional[ResourceOptions] = None)
    
    @overload
    def Service(resource_name: str,
                opts: Optional[ResourceOptions] = None,
                image: Optional[str] = None,
                project_name: Optional[str] = None,
                policies: Optional[Sequence[str]] = None,
                command: Optional[Sequence[str]] = None,
                depends_on: Optional[Mapping[str, _compose.ServiceDependencyArgs]] = None,
                deploy: Optional[_compose.DeployConfigArgs] = None,
                domain_name: Optional[str] = None,
                entrypoint: Optional[Sequence[str]] = None,
                environment: Optional[Mapping[str, str]] = None,
                aws: Optional[_aws.SharedInfraArgs] = None,
                ports: Optional[Sequence[_compose.ServicePortConfigArgs]] = None,
                platform: Optional[str] = None,
                container_name: Optional[str] = None,
                autoscaling: Optional[bool] = None,
                health_check: Optional[_compose.HealthCheckConfigArgs] = None,
                secrets: Optional[Mapping[str, str]] = None,
                security_group_ids: Optional[Sequence[str]] = None,
                sidecars: Optional[Mapping[str, _compose.ServiceConfigArgs]] = None,
                stop_grace_period: Optional[str] = None,
                task_role_arn: Optional[str] = None,
                triggers: Optional[Mapping[str, str]] = None,
                volumes: Optional[Sequence[_compose.ServiceVolumeConfigArgs]] = None,
                volumes_from: Optional[Sequence[str]] = None,
                wait_for_steady_state: Optional[bool] = None,
                working_dir: Optional[str] = None)
    func NewService(ctx *Context, name string, args ServiceArgs, opts ...ResourceOption) (*Service, error)
    public Service(string name, ServiceArgs args, ComponentResourceOptions? opts = null)
    public Service(String name, ServiceArgs args)
    public Service(String name, ServiceArgs args, ComponentResourceOptions options)
    
    type: defang-aws:Service
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "defang-aws_service" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args ServiceArgs
    The arguments to resource properties.
    opts ComponentResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ServiceArgs
    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 ServiceArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ServiceArgs
    The arguments to resource properties.
    opts ComponentResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ServiceArgs
    The arguments to resource properties.
    options ComponentResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var serviceResource = new DefangAws.Service("serviceResource", new()
    {
        Image = "string",
        ProjectName = "string",
        Policies = new[]
        {
            "string",
        },
        Command = new[]
        {
            "string",
        },
        DependsOn = 
        {
            { "string", new DefangAws.Compose.Inputs.ServiceDependencyArgs
            {
                Condition = "string",
                Required = false,
            } },
        },
        Deploy = new DefangAws.Compose.Inputs.DeployConfigArgs
        {
            Replicas = 0,
            Resources = new DefangAws.Compose.Inputs.ResourcesArgs
            {
                Reservations = new DefangAws.Compose.Inputs.ResourceConfigArgs
                {
                    Cpus = 0,
                    Memory = "string",
                },
            },
        },
        DomainName = "string",
        Entrypoint = new[]
        {
            "string",
        },
        Environment = 
        {
            { "string", "string" },
        },
        Aws = new DefangAws.Aws.Inputs.SharedInfraArgs
        {
            VpcID = "string",
            ClusterArn = "string",
            ExecutionRoleArn = "string",
            LogGroupName = "string",
            PrivateSgID = "string",
            PrivateSubnetIDs = new[]
            {
                "string",
            },
            PrivateZoneID = "string",
            PublicSubnetIDs = new[]
            {
                "string",
            },
        },
        Ports = new[]
        {
            new DefangAws.Compose.Inputs.ServicePortConfigArgs
            {
                Target = 0,
                AppProtocol = "string",
                Listener = "string",
                Mode = "string",
                Protocol = "string",
            },
        },
        Platform = "string",
        ContainerName = "string",
        Autoscaling = false,
        HealthCheck = new DefangAws.Compose.Inputs.HealthCheckConfigArgs
        {
            IntervalSeconds = 0,
            Retries = 0,
            StartPeriodSeconds = 0,
            Test = new[]
            {
                "string",
            },
            TimeoutSeconds = 0,
        },
        Secrets = 
        {
            { "string", "string" },
        },
        SecurityGroupIds = new[]
        {
            "string",
        },
        Sidecars = 
        {
            { "string", new DefangAws.Compose.Inputs.ServiceConfigArgs
            {
                Autoscaling = false,
                Build = new DefangAws.Compose.Inputs.BuildConfigArgs
                {
                    Context = "string",
                    Args = 
                    {
                        { "string", "string" },
                    },
                    CacheFrom = new[]
                    {
                        "string",
                    },
                    CacheTo = new[]
                    {
                        "string",
                    },
                    Dockerfile = "string",
                    Platforms = new[]
                    {
                        "string",
                    },
                    ShmSize = "string",
                    Target = "string",
                },
                Command = new[]
                {
                    "string",
                },
                ContainerName = "string",
                DependsOn = 
                {
                    { "string", new DefangAws.Compose.Inputs.ServiceDependencyArgs
                    {
                        Condition = "string",
                        Required = false,
                    } },
                },
                Deploy = new DefangAws.Compose.Inputs.DeployConfigArgs
                {
                    Replicas = 0,
                    Resources = new DefangAws.Compose.Inputs.ResourcesArgs
                    {
                        Reservations = new DefangAws.Compose.Inputs.ResourceConfigArgs
                        {
                            Cpus = 0,
                            Memory = "string",
                        },
                    },
                },
                DomainName = "string",
                Entrypoint = new[]
                {
                    "string",
                },
                Environment = 
                {
                    { "string", "string" },
                },
                HealthCheck = new DefangAws.Compose.Inputs.HealthCheckConfigArgs
                {
                    IntervalSeconds = 0,
                    Retries = 0,
                    StartPeriodSeconds = 0,
                    Test = new[]
                    {
                        "string",
                    },
                    TimeoutSeconds = 0,
                },
                Image = "string",
                Llm = null,
                NetworkMode = "string",
                Networks = 
                {
                    { "string", new DefangAws.Compose.Inputs.ServiceNetworkConfigArgs
                    {
                        Aliases = new[]
                        {
                            "string",
                        },
                    } },
                },
                Platform = "string",
                Policies = new[]
                {
                    "string",
                },
                Ports = new[]
                {
                    new DefangAws.Compose.Inputs.ServicePortConfigArgs
                    {
                        Target = 0,
                        AppProtocol = "string",
                        Listener = "string",
                        Mode = "string",
                        Protocol = "string",
                    },
                },
                Postgres = new DefangAws.Compose.Inputs.PostgresConfigArgs
                {
                    AllowDowntime = false,
                    FromSnapshot = "string",
                },
                Redis = new DefangAws.Compose.Inputs.RedisConfigArgs
                {
                    AllowDowntime = false,
                    FromSnapshot = "string",
                },
                Restart = "string",
                StopGracePeriod = "string",
                Volumes = new[]
                {
                    new DefangAws.Compose.Inputs.ServiceVolumeConfigArgs
                    {
                        Source = "string",
                        Target = "string",
                        ReadOnly = false,
                    },
                },
                VolumesFrom = new[]
                {
                    "string",
                },
                WorkingDir = "string",
            } },
        },
        StopGracePeriod = "string",
        TaskRoleArn = "string",
        Triggers = 
        {
            { "string", "string" },
        },
        Volumes = new[]
        {
            new DefangAws.Compose.Inputs.ServiceVolumeConfigArgs
            {
                Source = "string",
                Target = "string",
                ReadOnly = false,
            },
        },
        VolumesFrom = new[]
        {
            "string",
        },
        WaitForSteadyState = false,
        WorkingDir = "string",
    });
    
    example, err := defangaws.NewService(ctx, "serviceResource", &defangaws.ServiceArgs{
    	Image:       pulumi.String("string"),
    	ProjectName: "string",
    	Policies: pulumi.StringArray{
    		"string",
    	},
    	Command: pulumi.StringArray{
    		"string",
    	},
    	DependsOn: compose.ServiceDependencyMap{
    		"string": &compose.ServiceDependencyArgs{
    			Condition: pulumi.String("string"),
    			Required:  pulumi.Bool(false),
    		},
    	},
    	Deploy: &compose.DeployConfigArgs{
    		Replicas: pulumi.Int(0),
    		Resources: &compose.ResourcesArgs{
    			Reservations: &compose.ResourceConfigArgs{
    				Cpus:   pulumi.Float64(0),
    				Memory: pulumi.String("string"),
    			},
    		},
    	},
    	DomainName: "string",
    	Entrypoint: pulumi.StringArray{
    		"string",
    	},
    	Environment: pulumi.StringMap{
    		"string": "string",
    	},
    	Aws: &aws.SharedInfraArgs{
    		VpcID:            pulumi.String("string"),
    		ClusterArn:       pulumi.String("string"),
    		ExecutionRoleArn: pulumi.String("string"),
    		LogGroupName:     pulumi.String("string"),
    		PrivateSgID:      pulumi.String("string"),
    		PrivateSubnetIDs: pulumi.StringArray{
    			pulumi.String("string"),
    		},
    		PrivateZoneID: pulumi.String("string"),
    		PublicSubnetIDs: pulumi.StringArray{
    			pulumi.String("string"),
    		},
    	},
    	Ports: compose.ServicePortConfigArray{
    		&compose.ServicePortConfigArgs{
    			Target:      pulumi.Int(0),
    			AppProtocol: pulumi.String("string"),
    			Listener:    pulumi.String("string"),
    			Mode:        pulumi.String("string"),
    			Protocol:    pulumi.String("string"),
    		},
    	},
    	Platform:      "string",
    	ContainerName: "string",
    	Autoscaling:   false,
    	HealthCheck: &compose.HealthCheckConfigArgs{
    		IntervalSeconds:    pulumi.Int(0),
    		Retries:            pulumi.Int(0),
    		StartPeriodSeconds: pulumi.Int(0),
    		Test: pulumi.StringArray{
    			pulumi.String("string"),
    		},
    		TimeoutSeconds: pulumi.Int(0),
    	},
    	Secrets: pulumi.StringMap{
    		"string": "string",
    	},
    	SecurityGroupIds: pulumi.StringArray{
    		"string",
    	},
    	Sidecars: compose.ServiceConfigMap{
    		"string": &compose.ServiceConfigArgs{
    			Autoscaling: pulumi.Bool(false),
    			Build: &compose.BuildConfigArgs{
    				Context: pulumi.String("string"),
    				Args: pulumi.StringMap{
    					"string": pulumi.String("string"),
    				},
    				CacheFrom: pulumi.StringArray{
    					pulumi.String("string"),
    				},
    				CacheTo: pulumi.StringArray{
    					pulumi.String("string"),
    				},
    				Dockerfile: pulumi.String("string"),
    				Platforms: pulumi.StringArray{
    					pulumi.String("string"),
    				},
    				ShmSize: pulumi.String("string"),
    				Target:  pulumi.String("string"),
    			},
    			Command: pulumi.StringArray{
    				pulumi.String("string"),
    			},
    			ContainerName: pulumi.String("string"),
    			DependsOn: compose.ServiceDependencyMap{
    				"string": &compose.ServiceDependencyArgs{
    					Condition: pulumi.String("string"),
    					Required:  pulumi.Bool(false),
    				},
    			},
    			Deploy: &compose.DeployConfigArgs{
    				Replicas: pulumi.Int(0),
    				Resources: &compose.ResourcesArgs{
    					Reservations: &compose.ResourceConfigArgs{
    						Cpus:   pulumi.Float64(0),
    						Memory: pulumi.String("string"),
    					},
    				},
    			},
    			DomainName: pulumi.String("string"),
    			Entrypoint: pulumi.StringArray{
    				pulumi.String("string"),
    			},
    			Environment: pulumi.StringMap{
    				"string": pulumi.String("string"),
    			},
    			HealthCheck: &compose.HealthCheckConfigArgs{
    				IntervalSeconds:    pulumi.Int(0),
    				Retries:            pulumi.Int(0),
    				StartPeriodSeconds: pulumi.Int(0),
    				Test: pulumi.StringArray{
    					pulumi.String("string"),
    				},
    				TimeoutSeconds: pulumi.Int(0),
    			},
    			Image:       pulumi.String("string"),
    			Llm:         &compose.LlmConfigArgs{},
    			NetworkMode: pulumi.String("string"),
    			Networks: compose.ServiceNetworkConfigMap{
    				"string": &compose.ServiceNetworkConfigArgs{
    					Aliases: pulumi.StringArray{
    						pulumi.String("string"),
    					},
    				},
    			},
    			Platform: pulumi.String("string"),
    			Policies: pulumi.StringArray{
    				pulumi.String("string"),
    			},
    			Ports: compose.ServicePortConfigArray{
    				&compose.ServicePortConfigArgs{
    					Target:      pulumi.Int(0),
    					AppProtocol: pulumi.String("string"),
    					Listener:    pulumi.String("string"),
    					Mode:        pulumi.String("string"),
    					Protocol:    pulumi.String("string"),
    				},
    			},
    			Postgres: &compose.PostgresConfigArgs{
    				AllowDowntime: pulumi.Bool(false),
    				FromSnapshot:  pulumi.String("string"),
    			},
    			Redis: &compose.RedisConfigArgs{
    				AllowDowntime: pulumi.Bool(false),
    				FromSnapshot:  pulumi.String("string"),
    			},
    			Restart:         pulumi.String("string"),
    			StopGracePeriod: pulumi.String("string"),
    			Volumes: compose.ServiceVolumeConfigArray{
    				&compose.ServiceVolumeConfigArgs{
    					Source:   pulumi.String("string"),
    					Target:   pulumi.String("string"),
    					ReadOnly: pulumi.Bool(false),
    				},
    			},
    			VolumesFrom: pulumi.StringArray{
    				pulumi.String("string"),
    			},
    			WorkingDir: pulumi.String("string"),
    		},
    	},
    	StopGracePeriod: "string",
    	TaskRoleArn:     pulumi.String("string"),
    	Triggers: pulumi.StringMap{
    		"string": "string",
    	},
    	Volumes: compose.ServiceVolumeConfigArray{
    		&compose.ServiceVolumeConfigArgs{
    			Source:   pulumi.String("string"),
    			Target:   pulumi.String("string"),
    			ReadOnly: pulumi.Bool(false),
    		},
    	},
    	VolumesFrom: pulumi.StringArray{
    		"string",
    	},
    	WaitForSteadyState: false,
    	WorkingDir:         "string",
    })
    
    resource "defang-aws_service" "serviceResource" {
      image        = "string"
      project_name = "string"
      policies     = ["string"]
      command      = ["string"]
      depends_on = {
        "string" = {
          condition = "string"
          required  = false
        }
      }
      deploy = {
        replicas = 0
        resources = {
          reservations = {
            cpus   = 0
            memory = "string"
          }
        }
      }
      domain_name = "string"
      entrypoint  = ["string"]
      environment = {
        "string" = "string"
      }
      aws = {
        vpc_id              = "string"
        cluster_arn         = "string"
        execution_role_arn  = "string"
        log_group_name      = "string"
        private_sg_id       = "string"
        private_subnet_i_ds = ["string"]
        private_zone_id     = "string"
        public_subnet_i_ds  = ["string"]
      }
      ports {
        target       = 0
        app_protocol = "string"
        listener     = "string"
        mode         = "string"
        protocol     = "string"
      }
      platform       = "string"
      container_name = "string"
      autoscaling    = false
      health_check = {
        interval_seconds     = 0
        retries              = 0
        start_period_seconds = 0
        test                 = ["string"]
        timeout_seconds      = 0
      }
      secrets = {
        "string" = "string"
      }
      security_group_ids = ["string"]
      sidecars = {
        "string" = {
          autoscaling = false
          build = {
            context = "string"
            args = {
              "string" = "string"
            }
            cache_from = ["string"]
            cache_to   = ["string"]
            dockerfile = "string"
            platforms  = ["string"]
            shm_size   = "string"
            target     = "string"
          }
          command        = ["string"]
          container_name = "string"
          depends_on = {
            "string" = {
              condition = "string"
              required  = false
            }
          }
          deploy = {
            replicas = 0
            resources = {
              reservations = {
                cpus   = 0
                memory = "string"
              }
            }
          }
          domain_name = "string"
          entrypoint  = ["string"]
          environment = {
            "string" = "string"
          }
          health_check = {
            interval_seconds     = 0
            retries              = 0
            start_period_seconds = 0
            test                 = ["string"]
            timeout_seconds      = 0
          }
          image        = "string"
          llm          = {}
          network_mode = "string"
          networks = {
            "string" = {
              aliases = ["string"]
            }
          }
          platform = "string"
          policies = ["string"]
          ports = [{
            "target"      = 0
            "appProtocol" = "string"
            "listener"    = "string"
            "mode"        = "string"
            "protocol"    = "string"
          }]
          postgres = {
            allow_downtime = false
            from_snapshot  = "string"
          }
          redis = {
            allow_downtime = false
            from_snapshot  = "string"
          }
          restart           = "string"
          stop_grace_period = "string"
          volumes = [{
            "source"   = "string"
            "target"   = "string"
            "readOnly" = false
          }]
          volumes_from = ["string"]
          working_dir  = "string"
        }
      }
      stop_grace_period = "string"
      task_role_arn     = "string"
      triggers = {
        "string" = "string"
      }
      volumes {
        source    = "string"
        target    = "string"
        read_only = false
      }
      volumes_from          = ["string"]
      wait_for_steady_state = false
      working_dir           = "string"
    }
    
    var serviceResource = new Service("serviceResource", ServiceArgs.builder()
        .image("string")
        .projectName("string")
        .policies("string")
        .command("string")
        .dependsOn(Map.of("string", ServiceDependencyArgs.builder()
            .condition("string")
            .required(false)
            .build()))
        .deploy(DeployConfigArgs.builder()
            .replicas(0)
            .resources(ResourcesArgs.builder()
                .reservations(ResourceConfigArgs.builder()
                    .cpus(0.0)
                    .memory("string")
                    .build())
                .build())
            .build())
        .domainName("string")
        .entrypoint("string")
        .environment(Map.of("string", "string"))
        .aws(SharedInfraArgs.builder()
            .vpcID("string")
            .clusterArn("string")
            .executionRoleArn("string")
            .logGroupName("string")
            .privateSgID("string")
            .privateSubnetIDs("string")
            .privateZoneID("string")
            .publicSubnetIDs("string")
            .build())
        .ports(ServicePortConfigArgs.builder()
            .target(0)
            .appProtocol("string")
            .listener("string")
            .mode("string")
            .protocol("string")
            .build())
        .platform("string")
        .containerName("string")
        .autoscaling(false)
        .healthCheck(HealthCheckConfigArgs.builder()
            .intervalSeconds(0)
            .retries(0)
            .startPeriodSeconds(0)
            .test("string")
            .timeoutSeconds(0)
            .build())
        .secrets(Map.of("string", "string"))
        .securityGroupIds("string")
        .sidecars(Map.of("string", ServiceConfigArgs.builder()
            .autoscaling(false)
            .build(BuildConfigArgs.builder()
                .context("string")
                .args(Map.of("string", "string"))
                .cacheFrom("string")
                .cacheTo("string")
                .dockerfile("string")
                .platforms("string")
                .shmSize("string")
                .target("string")
                .build())
            .command("string")
            .containerName("string")
            .dependsOn(Map.of("string", ServiceDependencyArgs.builder()
                .condition("string")
                .required(false)
                .build()))
            .deploy(DeployConfigArgs.builder()
                .replicas(0)
                .resources(ResourcesArgs.builder()
                    .reservations(ResourceConfigArgs.builder()
                        .cpus(0.0)
                        .memory("string")
                        .build())
                    .build())
                .build())
            .domainName("string")
            .entrypoint("string")
            .environment(Map.of("string", "string"))
            .healthCheck(HealthCheckConfigArgs.builder()
                .intervalSeconds(0)
                .retries(0)
                .startPeriodSeconds(0)
                .test("string")
                .timeoutSeconds(0)
                .build())
            .image("string")
            .llm(LlmConfigArgs.builder()
                .build())
            .networkMode("string")
            .networks(Map.of("string", ServiceNetworkConfigArgs.builder()
                .aliases("string")
                .build()))
            .platform("string")
            .policies("string")
            .ports(ServicePortConfigArgs.builder()
                .target(0)
                .appProtocol("string")
                .listener("string")
                .mode("string")
                .protocol("string")
                .build())
            .postgres(PostgresConfigArgs.builder()
                .allowDowntime(false)
                .fromSnapshot("string")
                .build())
            .redis(RedisConfigArgs.builder()
                .allowDowntime(false)
                .fromSnapshot("string")
                .build())
            .restart("string")
            .stopGracePeriod("string")
            .volumes(ServiceVolumeConfigArgs.builder()
                .source("string")
                .target("string")
                .readOnly(false)
                .build())
            .volumesFrom("string")
            .workingDir("string")
            .build()))
        .stopGracePeriod("string")
        .taskRoleArn("string")
        .triggers(Map.of("string", "string"))
        .volumes(ServiceVolumeConfigArgs.builder()
            .source("string")
            .target("string")
            .readOnly(false)
            .build())
        .volumesFrom("string")
        .waitForSteadyState(false)
        .workingDir("string")
        .build());
    
    service_resource = defang_aws.Service("serviceResource",
        image="string",
        project_name="string",
        policies=["string"],
        command=["string"],
        depends_on={
            "string": {
                "condition": "string",
                "required": False,
            },
        },
        deploy={
            "replicas": 0,
            "resources": {
                "reservations": {
                    "cpus": float(0),
                    "memory": "string",
                },
            },
        },
        domain_name="string",
        entrypoint=["string"],
        environment={
            "string": "string",
        },
        aws={
            "vpc_id": "string",
            "cluster_arn": "string",
            "execution_role_arn": "string",
            "log_group_name": "string",
            "private_sg_id": "string",
            "private_subnet_ids": ["string"],
            "private_zone_id": "string",
            "public_subnet_ids": ["string"],
        },
        ports=[{
            "target": 0,
            "app_protocol": "string",
            "listener": "string",
            "mode": "string",
            "protocol": "string",
        }],
        platform="string",
        container_name="string",
        autoscaling=False,
        health_check={
            "interval_seconds": 0,
            "retries": 0,
            "start_period_seconds": 0,
            "test": ["string"],
            "timeout_seconds": 0,
        },
        secrets={
            "string": "string",
        },
        security_group_ids=["string"],
        sidecars={
            "string": {
                "autoscaling": False,
                "build": {
                    "context": "string",
                    "args": {
                        "string": "string",
                    },
                    "cache_from": ["string"],
                    "cache_to": ["string"],
                    "dockerfile": "string",
                    "platforms": ["string"],
                    "shm_size": "string",
                    "target": "string",
                },
                "command": ["string"],
                "container_name": "string",
                "depends_on": {
                    "string": {
                        "condition": "string",
                        "required": False,
                    },
                },
                "deploy": {
                    "replicas": 0,
                    "resources": {
                        "reservations": {
                            "cpus": float(0),
                            "memory": "string",
                        },
                    },
                },
                "domain_name": "string",
                "entrypoint": ["string"],
                "environment": {
                    "string": "string",
                },
                "health_check": {
                    "interval_seconds": 0,
                    "retries": 0,
                    "start_period_seconds": 0,
                    "test": ["string"],
                    "timeout_seconds": 0,
                },
                "image": "string",
                "llm": {},
                "network_mode": "string",
                "networks": {
                    "string": {
                        "aliases": ["string"],
                    },
                },
                "platform": "string",
                "policies": ["string"],
                "ports": [{
                    "target": 0,
                    "app_protocol": "string",
                    "listener": "string",
                    "mode": "string",
                    "protocol": "string",
                }],
                "postgres": {
                    "allow_downtime": False,
                    "from_snapshot": "string",
                },
                "redis": {
                    "allow_downtime": False,
                    "from_snapshot": "string",
                },
                "restart": "string",
                "stop_grace_period": "string",
                "volumes": [{
                    "source": "string",
                    "target": "string",
                    "read_only": False,
                }],
                "volumes_from": ["string"],
                "working_dir": "string",
            },
        },
        stop_grace_period="string",
        task_role_arn="string",
        triggers={
            "string": "string",
        },
        volumes=[{
            "source": "string",
            "target": "string",
            "read_only": False,
        }],
        volumes_from=["string"],
        wait_for_steady_state=False,
        working_dir="string")
    
    const serviceResource = new defang_aws.Service("serviceResource", {
        image: "string",
        projectName: "string",
        policies: ["string"],
        command: ["string"],
        dependsOn: {
            string: {
                condition: "string",
                required: false,
            },
        },
        deploy: {
            replicas: 0,
            resources: {
                reservations: {
                    cpus: 0,
                    memory: "string",
                },
            },
        },
        domainName: "string",
        entrypoint: ["string"],
        environment: {
            string: "string",
        },
        aws: {
            vpcID: "string",
            clusterArn: "string",
            executionRoleArn: "string",
            logGroupName: "string",
            privateSgID: "string",
            privateSubnetIDs: ["string"],
            privateZoneID: "string",
            publicSubnetIDs: ["string"],
        },
        ports: [{
            target: 0,
            appProtocol: "string",
            listener: "string",
            mode: "string",
            protocol: "string",
        }],
        platform: "string",
        containerName: "string",
        autoscaling: false,
        healthCheck: {
            intervalSeconds: 0,
            retries: 0,
            startPeriodSeconds: 0,
            test: ["string"],
            timeoutSeconds: 0,
        },
        secrets: {
            string: "string",
        },
        securityGroupIds: ["string"],
        sidecars: {
            string: {
                autoscaling: false,
                build: {
                    context: "string",
                    args: {
                        string: "string",
                    },
                    cacheFrom: ["string"],
                    cacheTo: ["string"],
                    dockerfile: "string",
                    platforms: ["string"],
                    shmSize: "string",
                    target: "string",
                },
                command: ["string"],
                containerName: "string",
                dependsOn: {
                    string: {
                        condition: "string",
                        required: false,
                    },
                },
                deploy: {
                    replicas: 0,
                    resources: {
                        reservations: {
                            cpus: 0,
                            memory: "string",
                        },
                    },
                },
                domainName: "string",
                entrypoint: ["string"],
                environment: {
                    string: "string",
                },
                healthCheck: {
                    intervalSeconds: 0,
                    retries: 0,
                    startPeriodSeconds: 0,
                    test: ["string"],
                    timeoutSeconds: 0,
                },
                image: "string",
                llm: {},
                networkMode: "string",
                networks: {
                    string: {
                        aliases: ["string"],
                    },
                },
                platform: "string",
                policies: ["string"],
                ports: [{
                    target: 0,
                    appProtocol: "string",
                    listener: "string",
                    mode: "string",
                    protocol: "string",
                }],
                postgres: {
                    allowDowntime: false,
                    fromSnapshot: "string",
                },
                redis: {
                    allowDowntime: false,
                    fromSnapshot: "string",
                },
                restart: "string",
                stopGracePeriod: "string",
                volumes: [{
                    source: "string",
                    target: "string",
                    readOnly: false,
                }],
                volumesFrom: ["string"],
                workingDir: "string",
            },
        },
        stopGracePeriod: "string",
        taskRoleArn: "string",
        triggers: {
            string: "string",
        },
        volumes: [{
            source: "string",
            target: "string",
            readOnly: false,
        }],
        volumesFrom: ["string"],
        waitForSteadyState: false,
        workingDir: "string",
    });
    
    type: defang-aws:Service
    properties:
        autoscaling: false
        aws:
            clusterArn: string
            executionRoleArn: string
            logGroupName: string
            privateSgID: string
            privateSubnetIDs:
                - string
            privateZoneID: string
            publicSubnetIDs:
                - string
            vpcID: string
        command:
            - string
        containerName: string
        dependsOn:
            string:
                condition: string
                required: false
        deploy:
            replicas: 0
            resources:
                reservations:
                    cpus: 0
                    memory: string
        domainName: string
        entrypoint:
            - string
        environment:
            string: string
        healthCheck:
            intervalSeconds: 0
            retries: 0
            startPeriodSeconds: 0
            test:
                - string
            timeoutSeconds: 0
        image: string
        platform: string
        policies:
            - string
        ports:
            - appProtocol: string
              listener: string
              mode: string
              protocol: string
              target: 0
        projectName: string
        secrets:
            string: string
        securityGroupIds:
            - string
        sidecars:
            string:
                autoscaling: false
                build:
                    args:
                        string: string
                    cacheFrom:
                        - string
                    cacheTo:
                        - string
                    context: string
                    dockerfile: string
                    platforms:
                        - string
                    shmSize: string
                    target: string
                command:
                    - string
                containerName: string
                dependsOn:
                    string:
                        condition: string
                        required: false
                deploy:
                    replicas: 0
                    resources:
                        reservations:
                            cpus: 0
                            memory: string
                domainName: string
                entrypoint:
                    - string
                environment:
                    string: string
                healthCheck:
                    intervalSeconds: 0
                    retries: 0
                    startPeriodSeconds: 0
                    test:
                        - string
                    timeoutSeconds: 0
                image: string
                llm: {}
                networkMode: string
                networks:
                    string:
                        aliases:
                            - string
                platform: string
                policies:
                    - string
                ports:
                    - appProtocol: string
                      listener: string
                      mode: string
                      protocol: string
                      target: 0
                postgres:
                    allowDowntime: false
                    fromSnapshot: string
                redis:
                    allowDowntime: false
                    fromSnapshot: string
                restart: string
                stopGracePeriod: string
                volumes:
                    - readOnly: false
                      source: string
                      target: string
                volumesFrom:
                    - string
                workingDir: string
        stopGracePeriod: string
        taskRoleArn: string
        triggers:
            string: string
        volumes:
            - readOnly: false
              source: string
              target: string
        volumesFrom:
            - string
        waitForSteadyState: false
        workingDir: string
    

    Service 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 Service resource accepts the following input properties:

    Image string
    ProjectName string
    Autoscaling bool
    Aws DefangLabs.DefangAws.Aws.Inputs.SharedInfra
    Command List<string>
    ContainerName string
    DependsOn Dictionary<string, DefangLabs.DefangAws.Compose.Inputs.ServiceDependencyArgs>
    Deploy DefangLabs.DefangAws.Compose.Inputs.DeployConfig
    DomainName string
    Entrypoint List<string>
    Environment Dictionary<string, string>
    HealthCheck DefangLabs.DefangAws.Compose.Inputs.HealthCheckConfig
    Platform string
    Policies List<string>
    Ports List<DefangLabs.DefangAws.Compose.Inputs.ServicePortConfig>
    Secrets Dictionary<string, string>
    SecurityGroupIds List<string>
    Sidecars Dictionary<string, DefangLabs.DefangAws.Compose.Inputs.ServiceConfigArgs>
    StopGracePeriod string
    TaskRoleArn string
    Triggers Dictionary<string, string>
    Volumes List<DefangLabs.DefangAws.Compose.Inputs.ServiceVolumeConfig>
    VolumesFrom List<string>
    WaitForSteadyState bool
    WorkingDir string
    image String
    projectName String
    autoscaling Boolean
    aws SharedInfra
    command List<String>
    containerName String
    dependsOn Map<String,ServiceDependencyArgs>
    deploy DeployConfig
    domainName String
    entrypoint List<String>
    environment Map<String,String>
    healthCheck HealthCheckConfig
    platform String
    policies List<String>
    ports List<ServicePortConfig>
    secrets Map<String,String>
    securityGroupIds List<String>
    sidecars Map<String,ServiceConfigArgs>
    stopGracePeriod String
    taskRoleArn String
    triggers Map<String,String>
    volumes List<ServiceVolumeConfig>
    volumesFrom List<String>
    waitForSteadyState Boolean
    workingDir String
    image string
    projectName string
    autoscaling boolean
    aws awsSharedInfra
    command string[]
    containerName string
    dependsOn {[key: string]: composeServiceDependencyArgs}
    deploy composeDeployConfig
    domainName string
    entrypoint string[]
    environment {[key: string]: string}
    healthCheck composeHealthCheckConfig
    platform string
    policies string[]
    ports composeServicePortConfig[]
    secrets {[key: string]: string}
    securityGroupIds string[]
    sidecars {[key: string]: composeServiceConfigArgs}
    stopGracePeriod string
    taskRoleArn string
    triggers {[key: string]: string}
    volumes composeServiceVolumeConfig[]
    volumesFrom string[]
    waitForSteadyState boolean
    workingDir string
    image String
    projectName String
    autoscaling Boolean
    aws Property Map
    command List<String>
    containerName String
    dependsOn Map<Property Map>
    deploy Property Map
    domainName String
    entrypoint List<String>
    environment Map<String>
    healthCheck Property Map
    platform String
    policies List<String>
    ports List<Property Map>
    secrets Map<String>
    securityGroupIds List<String>
    sidecars Map<Property Map>
    stopGracePeriod String
    taskRoleArn String
    triggers Map<String>
    volumes List<Property Map>
    volumesFrom List<String>
    waitForSteadyState Boolean
    workingDir String

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Service resource produces the following output properties:

    ClusterName string
    Endpoint string
    ServiceName string
    ClusterName string
    Endpoint string
    ServiceName string
    clusterName String
    endpoint String
    serviceName String
    clusterName string
    endpoint string
    serviceName string
    clusterName String
    endpoint String
    serviceName String

    Supporting Types

    BuildConfig, BuildConfigArgs

    Context string
    Args Dictionary<string, string>
    CacheFrom List<string>
    CacheTo List<string>
    Dockerfile string
    Platforms List<string>
    ShmSize string
    Target string
    Context string
    Args map[string]string
    CacheFrom []string
    CacheTo []string
    Dockerfile string
    Platforms []string
    ShmSize string
    Target string
    context string
    args map(string)
    cache_from list(string)
    cache_to list(string)
    dockerfile string
    platforms list(string)
    shm_size string
    target string
    context String
    args Map<String,String>
    cacheFrom List<String>
    cacheTo List<String>
    dockerfile String
    platforms List<String>
    shmSize String
    target String
    context string
    args {[key: string]: string}
    cacheFrom string[]
    cacheTo string[]
    dockerfile string
    platforms string[]
    shmSize string
    target string
    context str
    args Mapping[str, str]
    cache_from Sequence[str]
    cache_to Sequence[str]
    dockerfile str
    platforms Sequence[str]
    shm_size str
    target str
    context String
    args Map<String>
    cacheFrom List<String>
    cacheTo List<String>
    dockerfile String
    platforms List<String>
    shmSize String
    target String

    DeployConfig, DeployConfigArgs

    HealthCheckConfig, HealthCheckConfigArgs

    intervalSeconds Integer
    retries Integer
    startPeriodSeconds Integer
    test List<String>
    timeoutSeconds Integer
    intervalSeconds Number
    retries Number
    startPeriodSeconds Number
    test List<String>
    timeoutSeconds Number

    PostgresConfig, PostgresConfigArgs

    RedisConfig, RedisConfigArgs

    ResourceConfig, ResourceConfigArgs

    Cpus double
    Memory string
    Cpus float64
    Memory string
    cpus number
    memory string
    cpus Double
    memory String
    cpus number
    memory string
    cpus float
    memory str
    cpus Number
    memory String

    Resources, ResourcesArgs

    ServiceConfig, ServiceConfigArgs

    Autoscaling bool
    Build DefangLabs.DefangAws.Compose.Inputs.BuildConfig
    Command List<string>
    ContainerName string
    DependsOn Dictionary<string, DefangLabs.DefangAws.Compose.Inputs.ServiceDependency>
    Deploy DefangLabs.DefangAws.Compose.Inputs.DeployConfig
    DomainName string
    Entrypoint List<string>
    Environment Dictionary<string, string>
    HealthCheck DefangLabs.DefangAws.Compose.Inputs.HealthCheckConfig
    Image string
    Llm DefangLabs.DefangAws.Compose.Inputs.LlmConfig
    NetworkMode string
    Networks Dictionary<string, DefangLabs.DefangAws.Compose.Inputs.ServiceNetworkConfig>
    Platform string
    Policies List<string>
    Ports List<DefangLabs.DefangAws.Compose.Inputs.ServicePortConfig>
    Postgres DefangLabs.DefangAws.Compose.Inputs.PostgresConfig
    Redis DefangLabs.DefangAws.Compose.Inputs.RedisConfig
    Restart string
    StopGracePeriod string
    Volumes List<DefangLabs.DefangAws.Compose.Inputs.ServiceVolumeConfig>
    VolumesFrom List<string>
    WorkingDir string

    ServiceDependency, ServiceDependencyArgs

    Condition string
    Required bool
    Condition string
    Required bool
    condition string
    required bool
    condition String
    required Boolean
    condition string
    required boolean
    condition String
    required Boolean

    ServiceNetworkConfig, ServiceNetworkConfigArgs

    Aliases List<string>
    Aliases []string
    aliases list(string)
    aliases List<String>
    aliases string[]
    aliases Sequence[str]
    aliases List<String>

    ServicePortConfig, ServicePortConfigArgs

    Target int
    AppProtocol string
    Listener string
    Mode string
    Protocol string
    Target int
    AppProtocol string
    Listener string
    Mode string
    Protocol string
    target number
    app_protocol string
    listener string
    mode string
    protocol string
    target Integer
    appProtocol String
    listener String
    mode String
    protocol String
    target number
    appProtocol string
    listener string
    mode string
    protocol string
    target Number
    appProtocol String
    listener String
    mode String
    protocol String

    ServiceVolumeConfig, ServiceVolumeConfigArgs

    Source string
    Target string
    ReadOnly bool
    Source string
    Target string
    ReadOnly bool
    source string
    target string
    read_only bool
    source String
    target String
    readOnly Boolean
    source string
    target string
    readOnly boolean
    source String
    target String
    readOnly Boolean

    SharedInfra, SharedInfraArgs

    VpcID string
    ClusterArn string
    ExecutionRoleArn string
    LogGroupName string
    PrivateSgID string
    PrivateSubnetIDs List<string>
    PrivateZoneID string
    PublicSubnetIDs List<string>
    vpcID String
    clusterArn String
    executionRoleArn String
    logGroupName String
    privateSgID String
    privateSubnetIDs List<String>
    privateZoneID String
    publicSubnetIDs List<String>
    vpcID String
    clusterArn String
    executionRoleArn String
    logGroupName String
    privateSgID String
    privateSubnetIDs List<String>
    privateZoneID String
    publicSubnetIDs List<String>

    Package Details

    Repository
    defang-aws DefangLabs/pulumi-defang
    License
    Apache-2.0
    defang-aws logo
    Viewing docs for Defang AWS v2.4.1
    published on Saturday, Jul 11, 2026 by Defang

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial