Beispiel #1
0
        private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?options, Input <string>?id)
        {
            var defaultOptions = new CustomResourceOptions
            {
                Version = Utilities.Version,
                Aliases =
                {
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/latest:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20180801:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20181001:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20181101:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20190201:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20190401:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20190601:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20190701:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20190801:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20190901:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20191101:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20191201:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20200301:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20200401:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20200501:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20200601:ExpressRoutePort"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20200701:ExpressRoutePort"
                    },
                },
            };
            var merged = CustomResourceOptions.Merge(defaultOptions, options);

            // Override the ID if one was specified for consistency with other language SDKs.
            merged.Id = id ?? merged.Id;
            return(merged);
        }
Beispiel #2
0
        private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?options, Input <string>?id)
        {
            var defaultOptions = new CustomResourceOptions
            {
                Version = Utilities.Version,
                Aliases =
                {
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/latest:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20151101:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20160201:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20160701:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20160901:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20170510:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20180201:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20180501:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20190301:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20190501:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20190701:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20190801:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20191001:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20200601:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20200801:ResourceGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:resources/v20201001:ResourceGroup"
                    },
                },
            };
            var merged = CustomResourceOptions.Merge(defaultOptions, options);

            // Override the ID if one was specified for consistency with other language SDKs.
            merged.Id = id ?? merged.Id;
            return(merged);
        }
Beispiel #3
0
        private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?options, Input <string>?id)
        {
            var defaultOptions = new CustomResourceOptions
            {
                Version = Utilities.Version,
                Aliases =
                {
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/latest:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20150501preview:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20150615:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20160330:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20160601:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20160901:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20161201:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20170301:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20170601:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20170801:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20170901:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20171001:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20171101:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20180101:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20180201:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20180401:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20180601:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20180701:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20180801:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20181001:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20181101:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20181201:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20190201:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20190401:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20190701:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20190801:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20190901:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20191101:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20191201:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20200301:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20200401:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20200501:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20200601:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20200701:NetworkSecurityGroup"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:network/v20200801:NetworkSecurityGroup"
                    },
                },
            };
            var merged = CustomResourceOptions.Merge(defaultOptions, options);

            // Override the ID if one was specified for consistency with other language SDKs.
            merged.Id = id ?? merged.Id;
            return(merged);
        }
Beispiel #4
0
        private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?options, Input <string>?id)
        {
            var defaultOptions = new CustomResourceOptions
            {
                Version = Utilities.Version,
                Aliases =
                {
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/latest:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20170831:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20180331:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20180801preview:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20190201:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20190401:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20190601:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20190801:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20191001:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20191101:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20200101:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20200201:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20200301:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20200401:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20200601:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20200901:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20201101:ManagedCluster"
                    },
                    new Pulumi.Alias {
                        Type = "azure-nextgen:containerservice/v20201201:ManagedCluster"
                    },
                },
            };
            var merged = CustomResourceOptions.Merge(defaultOptions, options);

            // Override the ID if one was specified for consistency with other language SDKs.
            merged.Id = id ?? merged.Id;
            return(merged);
        }
Beispiel #5
0
        public Func <RegionalContext, IRegionalEndpoint> BuildVMScaleSetApp(GlobalContext context)
        {
            var options =
                CustomResourceOptions.Merge(context.Options, new CustomResourceOptions {
                DeleteBeforeReplace = true
            });
            var file = File.ReadAllText("./vm/vmCustomData.yaml");

            return((RegionalContext region) =>
            {
                var location = region.Location;
                var domainName = $"rnddnplm{location}"; //TODO: random

                var publicIp = new PublicIp($"pip-{location}", new PublicIpArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    Location = location,
                    AllocationMethod = "Static",
                    DomainNameLabel = domainName,
                },
                                            options);

                var loadBalancer = new LoadBalancer($"lb-{location}", new LoadBalancerArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    Location = location,
                    FrontendIpConfigurations =
                    {
                        new LoadBalancerFrontendIpConfigurationsArgs
                        {
                            Name = "PublicIPAddress",
                            PublicIpAddressId = publicIp.Id,
                        }
                    }
                },
                                                    options);

                var bpepool = new BackendAddressPool($"bap-{location}", new BackendAddressPoolArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    LoadbalancerId = loadBalancer.Id,
                },
                                                     options);

                var probe = new Probe($"ssh-probe-{location}".Truncate(16), new ProbeArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    LoadbalancerId = loadBalancer.Id,
                    Port = 80,
                },
                                      options);

                var rule = new Rule($"rule-{location}", new RuleArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    BackendAddressPoolId = bpepool.Id,
                    BackendPort = 80,
                    FrontendIpConfigurationName = "PublicIPAddress",
                    FrontendPort = 80,
                    LoadbalancerId = loadBalancer.Id,
                    ProbeId = probe.Id,
                    Protocol = "Tcp",
                },
                                    options);

                var vnet = new VirtualNetwork($"vnet-{location}", new VirtualNetworkArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    Location = location,
                    AddressSpaces = { "10.0.0.0/16" },
                },
                                              options);

                var subnet = new Subnet($"subnet-{location}", new SubnetArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    AddressPrefix = "10.0.2.0/24",
                    VirtualNetworkName = vnet.Name,
                },
                                        options);

                var customData = Output.All <string>(context.CosmosAccount.Endpoint,
                                                     context.CosmosAccount.PrimaryMasterKey, context.Database.Name, context.Container.Name)
                                 .Apply(values =>
                {
                    return file.Replace("${ENDPOINT}", values[0])
                    .Replace("${MASTER_KEY}", values[1])
                    .Replace("${DATABASE}", values[2])
                    .Replace("${COLLECTION}", values[3])
                    .Replace("${LOCATION}", location);
                });

                var scaleSet = new ScaleSet($"vmss-{location}", new ScaleSetArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    Location = location,
                    NetworkProfiles =
                    {
                        new ScaleSetNetworkProfilesArgs
                        {
                            IpConfigurations =
                            {
                                new ScaleSetNetworkProfilesIpConfigurationsArgs
                                {
                                    LoadBalancerBackendAddressPoolIds ={ bpepool.Id                                         },
                                    Name = "IPConfiguration",
                                    Primary = true,
                                    SubnetId = subnet.Id,
                                }
                            },
                            Name = "networkprofile",
                            Primary = true,
                        }
                    },
                    OsProfile = new ScaleSetOsProfileArgs
                    {
                        AdminUsername = "******",
                        AdminPassword = "******",
                        ComputerNamePrefix = "lab",
                        CustomData = customData,
                    },
                    OsProfileLinuxConfig = new ScaleSetOsProfileLinuxConfigArgs
                    {
                        DisablePasswordAuthentication = false
                    },
                    Sku = new ScaleSetSkuArgs
                    {
                        Capacity = 1,
                        Name = "Standard_DS1_v2",
                        Tier = "Standard",
                    },
                    StorageProfileDataDisks =
                    {
                        new ScaleSetStorageProfileDataDisksArgs
                        {
                            Caching = "ReadWrite",
                            CreateOption = "Empty",
                            DiskSizeGb = 10,
                            Lun = 0,
                        }
                    },
                    StorageProfileImageReference = new ScaleSetStorageProfileImageReferenceArgs
                    {
                        Offer = "UbuntuServer",
                        Publisher = "Canonical",
                        Sku = "18.04-LTS",
                        Version = "latest",
                    },
                    StorageProfileOsDisk = new ScaleSetStorageProfileOsDiskArgs
                    {
                        Caching = "ReadWrite",
                        CreateOption = "FromImage",
                        ManagedDiskType = "Standard_LRS",
                        Name = "",
                    },
                    UpgradePolicyMode = "Automatic",
                },
                                            CustomResourceOptions.Merge(options, new CustomResourceOptions {
                    DependsOn = { bpepool, rule }
                }));

                var autoscale = new AutoscaleSetting($"as-{location}", new AutoscaleSettingArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    Location = location,
                    Notification = new AutoscaleSettingNotificationArgs
                    {
                        Email = new AutoscaleSettingNotificationEmailArgs
                        {
                            CustomEmails = { "*****@*****.**" },
                            SendToSubscriptionAdministrator = true,
                            SendToSubscriptionCoAdministrator = true,
                        },
                    },
                    Profiles =
                    {
                        new AutoscaleSettingProfilesArgs
                        {
                            Capacity = new AutoscaleSettingProfilesCapacityArgs
                            {
                                Default = 1,
                                Maximum = 10,
                                Minimum = 1,
                            },
                            Name = "defaultProfile",
                            Rules =
                            {
                                new AutoscaleSettingProfilesRulesArgs
                                {
                                    MetricTrigger = new AutoscaleSettingProfilesRulesMetricTriggerArgs
                                    {
                                        MetricName = "Percentage CPU",
                                        MetricResourceId = scaleSet.Id,
                                        Operator = "GreaterThan",
                                        Statistic = "Average",
                                        Threshold = 75,
                                        TimeAggregation = "Average",
                                        TimeGrain = "PT1M",
                                        TimeWindow = "PT5M",
                                    },
                                    ScaleAction = new AutoscaleSettingProfilesRulesScaleActionArgs
                                    {
                                        Cooldown = "PT1M",
                                        Direction = "Increase",
                                        Type = "ChangeCount",
                                        Value = 1,
                                    },
                                },
                                new AutoscaleSettingProfilesRulesArgs
                                {
                                    MetricTrigger = new AutoscaleSettingProfilesRulesMetricTriggerArgs
                                    {
                                        MetricName = "Percentage CPU",
                                        MetricResourceId = scaleSet.Id,
                                        Operator = "LessThan",
                                        Statistic = "Average",
                                        Threshold = 25,
                                        TimeAggregation = "Average",
                                        TimeGrain = "PT1M",
                                        TimeWindow = "PT5M",
                                    },
                                    ScaleAction = new AutoscaleSettingProfilesRulesScaleActionArgs
                                    {
                                        Cooldown = "PT1M",
                                        Direction = "Decrease",
                                        Type = "ChangeCount",
                                        Value = 1,
                                    },
                                },
                            }
                        }
                    },
                    TargetResourceId = scaleSet.Id,
                },
                                                     options);

                return new AzureEndpoint(publicIp.Id);
            });
        }