forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
60 lines (55 loc) · 1.8 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
package main
import (
"github.com/pulumi/pulumi-azure-native/sdk/go/azure/containerinstance"
"github.com/pulumi/pulumi-azure-native/sdk/go/azure/resources"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
resourceGroup, err := resources.NewResourceGroup(ctx, "aci-rg", nil)
if err != nil {
return err
}
imageName := "mcr.microsoft.com/azuredocs/aci-helloworld"
containerGroup, err := containerinstance.NewContainerGroup(ctx, "helloworld", &containerinstance.ContainerGroupArgs{
ResourceGroupName: resourceGroup.Name,
OsType: pulumi.String("Linux"),
Containers: &containerinstance.ContainerArray{
&containerinstance.ContainerArgs{
Name: pulumi.String("acilinuxpublicipcontainergroup"),
Image: pulumi.String(imageName),
Ports: &containerinstance.ContainerPortArray{
&containerinstance.ContainerPortArgs{Port: pulumi.Int(80)},
},
Resources: &containerinstance.ResourceRequirementsArgs{
Requests: &containerinstance.ResourceRequestsArgs{
Cpu: pulumi.Float64(1.0),
MemoryInGB: pulumi.Float64(1.5),
},
},
},
},
IpAddress: &containerinstance.IpAddressArgs{
Ports: &containerinstance.PortArray{
&containerinstance.PortArgs{
Port: pulumi.Int(80),
Protocol: pulumi.String("Tcp"),
},
},
Type: pulumi.String("Public"),
},
RestartPolicy: pulumi.String("always"),
})
if err != nil {
return err
}
ctx.Export("containerIPv4Address", containerGroup.IpAddress.ApplyT(func(ip *containerinstance.IpAddressResponse) (string, error) {
if ip == nil || ip.Ip == nil {
return "", nil
}
return *ip.Ip, nil
}).(pulumi.StringOutput))
return nil
})
}