Skip to content

Commit

Permalink
Update azure-go-webserver-component (pulumi#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasia Halim authored Feb 18, 2020
1 parent ee51d32 commit babaae1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions azure-go-webserver-component/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func main() {
network, err := network.NewVirtualNetwork(ctx, "server-network", &network.VirtualNetworkArgs{
ResourceGroupName: rg.Name,
AddressSpaces: pulumi.StringArray{pulumi.String("10.0.0.0/16")},
Subnets: network.VirtualNetworkSubnetsArrayArgs{
network.VirtualNetworkSubnetsArgs{
Subnets: network.VirtualNetworkSubnetArray{
network.VirtualNetworkSubnetArgs{
Name: pulumi.String("default"),
AddressPrefix: pulumi.String("10.0.1.0/24"),
},
Expand All @@ -51,7 +51,7 @@ func main() {
echo "Hello, from Server %v!" > index.html
nohup python -m SimpleHTTPServer 80 &`, i)),
ResourceGroupName: rg.Name,
SubnetID: network.Subnets.Index(pulumi.Int(0)).Id(),
SubnetID: network.Subnets.Index(pulumi.Int(0)).Id().ToStringPtrOutput().Elem(),
})
if err != nil {
return err
Expand Down
15 changes: 7 additions & 8 deletions azure-go-webserver-component/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ type WebserverArgs struct {
// NewWebserver allocates a new web server VM, NIC, and public IP address.
func NewWebserver(ctx *pulumi.Context, name string, args *WebserverArgs, opts ...pulumi.ResourceOption) (*Webserver, error) {
webserver := &Webserver{}
reg, err := ctx.RegisterComponentResource("ws-ts-azure-comp:webserver:WebServer", name, webserver, opts...)
err := ctx.RegisterComponentResource("ws-ts-azure-comp:webserver:WebServer", name, webserver, opts...)
if err != nil {
return nil, err
}
defer reg.Close()

webserver.PublicIP, err = network.NewPublicIp(ctx, name+"-ip", &network.PublicIpArgs{
ResourceGroupName: args.ResourceGroupName,
Expand All @@ -56,10 +55,10 @@ func NewWebserver(ctx *pulumi.Context, name string, args *WebserverArgs, opts ..

webserver.NetworkInterface, err = network.NewNetworkInterface(ctx, name+"-nic", &network.NetworkInterfaceArgs{
ResourceGroupName: args.ResourceGroupName,
IpConfigurations: network.NetworkInterfaceIpConfigurationsArrayArgs{
network.NetworkInterfaceIpConfigurationsArgs{
IpConfigurations: network.NetworkInterfaceIpConfigurationArray{
network.NetworkInterfaceIpConfigurationArgs{
Name: pulumi.String("webserveripcfg"),
SubnetId: args.SubnetID,
SubnetId: args.SubnetID.ToStringOutput(),
PrivateIpAddressAllocation: pulumi.String("Dynamic"),
PublicIpAddressId: webserver.PublicIP.ID(),
},
Expand All @@ -84,8 +83,8 @@ func NewWebserver(ctx *pulumi.Context, name string, args *WebserverArgs, opts ..
OsProfile: compute.VirtualMachineOsProfileArgs{
ComputerName: pulumi.String("hostname"),
AdminUsername: args.Username,
AdminPassword: args.Password,
CustomData: args.BootScript,
AdminPassword: args.Password.ToStringOutput(),
CustomData: args.BootScript.ToStringOutput(),
},
OsProfileLinuxConfig: compute.VirtualMachineOsProfileLinuxConfigArgs{
DisablePasswordAuthentication: pulumi.Bool(false),
Expand Down Expand Up @@ -115,7 +114,7 @@ func (ws *Webserver) GetIPAddress(ctx *pulumi.Context) pulumi.StringOutput {
return ready.ApplyT(func(args []interface{}) (string, error) {
name := args[1].(string)
resourceGroupName := args[2].(string)
ip, err := network.LookupPublicIP(ctx, &network.GetPublicIPArgs{
ip, err := network.GetPublicIP(ctx, &network.GetPublicIPArgs{
Name: name,
ResourceGroupName: resourceGroupName,
})
Expand Down

0 comments on commit babaae1

Please sign in to comment.