ContainerGroup

class ContainerGroup : KotlinCustomResource

A container group. API Version: 2021-03-01.

Example Usage

ContainerGroupsCreateOrUpdate

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var containerGroup = new AzureNative.ContainerInstance.ContainerGroup("containerGroup", new()
{
ContainerGroupName = "demo1",
Containers = new[]
{
new AzureNative.ContainerInstance.Inputs.ContainerArgs
{
Command = new[] {},
EnvironmentVariables = new[] {},
Image = "nginx",
Name = "demo1",
Ports = new[]
{
new AzureNative.ContainerInstance.Inputs.ContainerPortArgs
{
Port = 80,
},
},
Resources = new AzureNative.ContainerInstance.Inputs.ResourceRequirementsArgs
{
Requests = new AzureNative.ContainerInstance.Inputs.ResourceRequestsArgs
{
Cpu = 1,
Gpu = new AzureNative.ContainerInstance.Inputs.GpuResourceArgs
{
Count = 1,
Sku = "K80",
},
MemoryInGB = 1.5,
},
},
VolumeMounts = new[]
{
new AzureNative.ContainerInstance.Inputs.VolumeMountArgs
{
MountPath = "/mnt/volume1",
Name = "volume1",
ReadOnly = false,
},
new AzureNative.ContainerInstance.Inputs.VolumeMountArgs
{
MountPath = "/mnt/volume2",
Name = "volume2",
ReadOnly = false,
},
new AzureNative.ContainerInstance.Inputs.VolumeMountArgs
{
MountPath = "/mnt/volume3",
Name = "volume3",
ReadOnly = true,
},
},
},
},
Diagnostics = new AzureNative.ContainerInstance.Inputs.ContainerGroupDiagnosticsArgs
{
LogAnalytics = new AzureNative.ContainerInstance.Inputs.LogAnalyticsArgs
{
LogType = "ContainerInsights",
Metadata =
{
{ "test-key", "test-metadata-value" },
},
WorkspaceId = "workspaceid",
WorkspaceKey = "workspaceKey",
},
},
DnsConfig = new AzureNative.ContainerInstance.Inputs.DnsConfigurationArgs
{
NameServers = new[]
{
"1.1.1.1",
},
Options = "ndots:2",
SearchDomains = "cluster.local svc.cluster.local",
},
Identity = new AzureNative.ContainerInstance.Inputs.ContainerGroupIdentityArgs
{
Type = AzureNative.ContainerInstance.ResourceIdentityType.SystemAssigned_UserAssigned,
UserAssignedIdentities =
{
{ "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name", null },
},
},
ImageRegistryCredentials = new[] {},
IpAddress = new AzureNative.ContainerInstance.Inputs.IpAddressArgs
{
DnsNameLabel = "dnsnamelabel1",
Ports = new[]
{
new AzureNative.ContainerInstance.Inputs.PortArgs
{
Port = 80,
Protocol = "TCP",
},
},
Type = "Public",
},
Location = "west us",
NetworkProfile = new AzureNative.ContainerInstance.Inputs.ContainerGroupNetworkProfileArgs
{
Id = "test-network-profile-id",
},
OsType = "Linux",
ResourceGroupName = "demo",
Volumes = new[]
{
new AzureNative.ContainerInstance.Inputs.VolumeArgs
{
AzureFile = new AzureNative.ContainerInstance.Inputs.AzureFileVolumeArgs
{
ShareName = "shareName",
StorageAccountKey = "accountKey",
StorageAccountName = "accountName",
},
Name = "volume1",
},
new AzureNative.ContainerInstance.Inputs.VolumeArgs
{
EmptyDir = null,
Name = "volume2",
},
new AzureNative.ContainerInstance.Inputs.VolumeArgs
{
Name = "volume3",
Secret =
{
{ "secretKey1", "SecretValue1InBase64" },
{ "secretKey2", "SecretValue2InBase64" },
},
},
},
});
});
package main
import (
containerinstance "github.com/pulumi/pulumi-azure-native-sdk/containerinstance"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := containerinstance.NewContainerGroup(ctx, "containerGroup", &containerinstance.ContainerGroupArgs{
ContainerGroupName: pulumi.String("demo1"),
Containers: []containerinstance.ContainerArgs{
{
Command: pulumi.StringArray{},
EnvironmentVariables: containerinstance.EnvironmentVariableArray{},
Image: pulumi.String("nginx"),
Name: pulumi.String("demo1"),
Ports: containerinstance.ContainerPortArray{
{
Port: pulumi.Int(80),
},
},
Resources: {
Requests: {
Cpu: pulumi.Float64(1),
Gpu: {
Count: pulumi.Int(1),
Sku: pulumi.String("K80"),
},
MemoryInGB: pulumi.Float64(1.5),
},
},
VolumeMounts: containerinstance.VolumeMountArray{
{
MountPath: pulumi.String("/mnt/volume1"),
Name: pulumi.String("volume1"),
ReadOnly: pulumi.Bool(false),
},
{
MountPath: pulumi.String("/mnt/volume2"),
Name: pulumi.String("volume2"),
ReadOnly: pulumi.Bool(false),
},
{
MountPath: pulumi.String("/mnt/volume3"),
Name: pulumi.String("volume3"),
ReadOnly: pulumi.Bool(true),
},
},
},
},
Diagnostics: containerinstance.ContainerGroupDiagnosticsResponse{
LogAnalytics: &containerinstance.LogAnalyticsArgs{
LogType: pulumi.String("ContainerInsights"),
Metadata: pulumi.StringMap{
"test-key": pulumi.String("test-metadata-value"),
},
WorkspaceId: pulumi.String("workspaceid"),
WorkspaceKey: pulumi.String("workspaceKey"),
},
},
DnsConfig: &containerinstance.DnsConfigurationArgs{
NameServers: pulumi.StringArray{
pulumi.String("1.1.1.1"),
},
Options: pulumi.String("ndots:2"),
SearchDomains: pulumi.String("cluster.local svc.cluster.local"),
},
Identity: &containerinstance.ContainerGroupIdentityArgs{
Type: containerinstance.ResourceIdentityType_SystemAssigned_UserAssigned,
UserAssignedIdentities: pulumi.AnyMap{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": nil,
},
},
ImageRegistryCredentials: containerinstance.ImageRegistryCredentialArray{},
IpAddress: containerinstance.IpAddressResponse{
DnsNameLabel: pulumi.String("dnsnamelabel1"),
Ports: containerinstance.PortArray{
&containerinstance.PortArgs{
Port: pulumi.Int(80),
Protocol: pulumi.String("TCP"),
},
},
Type: pulumi.String("Public"),
},
Location: pulumi.String("west us"),
NetworkProfile: &containerinstance.ContainerGroupNetworkProfileArgs{
Id: pulumi.String("test-network-profile-id"),
},
OsType: pulumi.String("Linux"),
ResourceGroupName: pulumi.String("demo"),
Volumes: []containerinstance.VolumeArgs{
{
AzureFile: {
ShareName: pulumi.String("shareName"),
StorageAccountKey: pulumi.String("accountKey"),
StorageAccountName: pulumi.String("accountName"),
},
Name: pulumi.String("volume1"),
},
{
EmptyDir: nil,
Name: pulumi.String("volume2"),
},
{
Name: pulumi.String("volume3"),
Secret: {
"secretKey1": pulumi.String("SecretValue1InBase64"),
"secretKey2": pulumi.String("SecretValue2InBase64"),
},
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.containerinstance.ContainerGroup;
import com.pulumi.azurenative.containerinstance.ContainerGroupArgs;
import java.util.List;
import java.util.ArrayList;
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) {
var containerGroup = new ContainerGroup("containerGroup", ContainerGroupArgs.builder()
.containerGroupName("demo1")
.containers(Map.ofEntries(
Map.entry("command", ),
Map.entry("environmentVariables", ),
Map.entry("image", "nginx"),
Map.entry("name", "demo1"),
Map.entry("ports", Map.of("port", 80)),
Map.entry("resources", Map.of("requests", Map.ofEntries(
Map.entry("cpu", 1),
Map.entry("gpu", Map.ofEntries(
Map.entry("count", 1),
Map.entry("sku", "K80")
)),
Map.entry("memoryInGB", 1.5)
))),
Map.entry("volumeMounts",
Map.ofEntries(
Map.entry("mountPath", "/mnt/volume1"),
Map.entry("name", "volume1"),
Map.entry("readOnly", false)
),
Map.ofEntries(
Map.entry("mountPath", "/mnt/volume2"),
Map.entry("name", "volume2"),
Map.entry("readOnly", false)
),
Map.ofEntries(
Map.entry("mountPath", "/mnt/volume3"),
Map.entry("name", "volume3"),
Map.entry("readOnly", true)
))
))
.diagnostics(Map.of("logAnalytics", Map.ofEntries(
Map.entry("logType", "ContainerInsights"),
Map.entry("metadata", Map.of("test-key", "test-metadata-value")),
Map.entry("workspaceId", "workspaceid"),
Map.entry("workspaceKey", "workspaceKey")
)))
.dnsConfig(Map.ofEntries(
Map.entry("nameServers", "1.1.1.1"),
Map.entry("options", "ndots:2"),
Map.entry("searchDomains", "cluster.local svc.cluster.local")
))
.identity(Map.ofEntries(
Map.entry("type", "SystemAssigned, UserAssigned"),
Map.entry("userAssignedIdentities", Map.of("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name", ))
))
.imageRegistryCredentials()
.ipAddress(Map.ofEntries(
Map.entry("dnsNameLabel", "dnsnamelabel1"),
Map.entry("ports", Map.ofEntries(
Map.entry("port", 80),
Map.entry("protocol", "TCP")
)),
Map.entry("type", "Public")
))
.location("west us")
.networkProfile(Map.of("id", "test-network-profile-id"))
.osType("Linux")
.resourceGroupName("demo")
.volumes(
Map.ofEntries(
Map.entry("azureFile", Map.ofEntries(
Map.entry("shareName", "shareName"),
Map.entry("storageAccountKey", "accountKey"),
Map.entry("storageAccountName", "accountName")
)),
Map.entry("name", "volume1")
),
Map.ofEntries(
Map.entry("emptyDir", ),
Map.entry("name", "volume2")
),
Map.ofEntries(
Map.entry("name", "volume3"),
Map.entry("secret", Map.ofEntries(
Map.entry("secretKey1", "SecretValue1InBase64"),
Map.entry("secretKey2", "SecretValue2InBase64")
))
))
.build());
}
}

Import

An existing resource can be imported using its type token, name, and identifier, e.g.

$ pulumi import azure-native:containerinstance:ContainerGroup demo1 /subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1

Properties

Link copied to clipboard

The containers within the container group.

Link copied to clipboard

The diagnostic information for a container group.

Link copied to clipboard

The DNS config information for a container group.

Link copied to clipboard

The encryption properties for a container group.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard

The identity of the container group, if configured.

Link copied to clipboard

The image registry credentials by which the container group is created from.

Link copied to clipboard

The init containers for a container group.

Link copied to clipboard

The instance view of the container group. Only valid in response.

Link copied to clipboard

The IP address type of the container group.

Link copied to clipboard
val location: Output<String>?

The resource location.

Link copied to clipboard
val name: Output<String>

The resource name.

Link copied to clipboard

The network profile information for a container group.

Link copied to clipboard
val osType: Output<String>

The operating system type required by the containers in the container group.

Link copied to clipboard

The provisioning state of the container group. This only appears in the response.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val restartPolicy: Output<String>?

Restart policy for all containers within the container group.

Link copied to clipboard
val sku: Output<String>?

The SKU for a container group.

Link copied to clipboard
val tags: Output<Map<String, String>>?

The resource tags.

Link copied to clipboard
val type: Output<String>

The resource type.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val volumes: Output<List<VolumeResponse>>?

The list of volumes that can be mounted by containers in this container group.