UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

310 lines • 13.1 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.SpotFleetRequest = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Provides an EC2 Spot Fleet Request resource. This allows a fleet of Spot * instances to be requested on the Spot market. * * > **NOTE [AWS strongly discourages](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-best-practices.html#which-spot-request-method-to-use) the use of the legacy APIs called by this resource. * We recommend using the EC2 Fleet or Auto Scaling Group resources instead. * * ## Example Usage * * ### Using launch specifications * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // Request a Spot fleet * const cheapCompute = new aws.ec2.SpotFleetRequest("cheap_compute", { * iamFleetRole: "arn:aws:iam::12345678:role/spot-fleet", * spotPrice: "0.03", * allocationStrategy: "diversified", * targetCapacity: 6, * validUntil: "2019-11-04T20:44:20Z", * launchSpecifications: [ * { * instanceType: "m4.10xlarge", * ami: "ami-1234", * spotPrice: "2.793", * placementTenancy: "dedicated", * iamInstanceProfileArn: example.arn, * }, * { * instanceType: "m4.4xlarge", * ami: "ami-5678", * keyName: "my-key", * spotPrice: "1.117", * iamInstanceProfileArn: example.arn, * availabilityZone: "us-west-1a", * subnetId: "subnet-1234", * weightedCapacity: "35", * rootBlockDevices: [{ * volumeSize: 300, * volumeType: "gp2", * }], * tags: { * Name: "spot-fleet-example", * }, * }, * ], * }); * ``` * * ### Using launch templates * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const foo = new aws.ec2.LaunchTemplate("foo", { * name: "launch-template", * imageId: "ami-516b9131", * instanceType: "m1.small", * keyName: "some-key", * }); * const fooSpotFleetRequest = new aws.ec2.SpotFleetRequest("foo", { * iamFleetRole: "arn:aws:iam::12345678:role/spot-fleet", * spotPrice: "0.005", * targetCapacity: 2, * validUntil: "2019-11-04T20:44:20Z", * launchTemplateConfigs: [{ * launchTemplateSpecification: { * id: foo.id, * version: foo.latestVersion, * }, * }], * }, { * dependsOn: [test_attach], * }); * ``` * * > **NOTE:** This provider does not support the functionality where multiple `subnetId` or `availabilityZone` parameters can be specified in the same * launch configuration block. If you want to specify multiple values, then separate launch configuration blocks should be used or launch template overrides should be configured, one per subnet: * * ### Using multiple launch specifications * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const foo = new aws.ec2.SpotFleetRequest("foo", { * iamFleetRole: "arn:aws:iam::12345678:role/spot-fleet", * spotPrice: "0.005", * targetCapacity: 2, * validUntil: "2019-11-04T20:44:20Z", * launchSpecifications: [ * { * instanceType: "m1.small", * ami: "ami-d06a90b0", * keyName: "my-key", * availabilityZone: "us-west-2a", * }, * { * instanceType: "m5.large", * ami: "ami-d06a90b0", * keyName: "my-key", * availabilityZone: "us-west-2a", * }, * ], * }); * ``` * * > In this example, we use a `dynamic` block to define zero or more `launchSpecification` blocks, producing one for each element in the list of subnet ids. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const config = new pulumi.Config(); * const subnets = config.requireObject<any>("subnets"); * const example = new aws.ec2.SpotFleetRequest("example", { * launchSpecifications: .map(s => ({ * subnetId: s[1], * })).map((v, k) => ({key: k, value: v})).map(entry => ({ * ami: "ami-1234", * instanceType: "m4.4xlarge", * subnetId: entry.value.subnetId, * vpcSecurityGroupIds: "sg-123456", * rootBlockDevices: [{ * volumeSize: 8, * volumeType: "gp2", * deleteOnTermination: true, * }], * tags: { * Name: "Spot Node", * tag_builder: "builder", * }, * })), * iamFleetRole: "arn:aws:iam::12345678:role/spot-fleet", * targetCapacity: 3, * validUntil: "2019-11-04T20:44:20Z", * allocationStrategy: "lowestPrice", * fleetType: "request", * waitForFulfillment: true, * terminateInstancesWithExpiration: true, * }); * ``` * * ### Using multiple launch configurations * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.ec2.getSubnets({ * filters: [{ * name: "vpc-id", * values: [vpcId], * }], * }); * const foo = new aws.ec2.LaunchTemplate("foo", { * name: "launch-template", * imageId: "ami-516b9131", * instanceType: "m1.small", * keyName: "some-key", * }); * const fooSpotFleetRequest = new aws.ec2.SpotFleetRequest("foo", { * iamFleetRole: "arn:aws:iam::12345678:role/spot-fleet", * spotPrice: "0.005", * targetCapacity: 2, * validUntil: "2019-11-04T20:44:20Z", * launchTemplateConfigs: [{ * launchTemplateSpecification: { * id: foo.id, * version: foo.latestVersion, * }, * overrides: [ * { * subnetId: example.then(example => example.ids?.[0]), * }, * { * subnetId: example.then(example => example.ids?.[1]), * }, * { * subnetId: example.then(example => example.ids?.[2]), * }, * ], * }], * }, { * dependsOn: [test_attach], * }); * ``` * * ## Import * * Using `pulumi import`, import Spot Fleet Requests using `id`. For example: * * ```sh * $ pulumi import aws:ec2/spotFleetRequest:SpotFleetRequest fleet sfr-005e9ec8-5546-4c31-b317-31a62325411e * ``` */ class SpotFleetRequest extends pulumi.CustomResource { /** * Get an existing SpotFleetRequest resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new SpotFleetRequest(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of SpotFleetRequest. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === SpotFleetRequest.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["allocationStrategy"] = state?.allocationStrategy; resourceInputs["clientToken"] = state?.clientToken; resourceInputs["context"] = state?.context; resourceInputs["excessCapacityTerminationPolicy"] = state?.excessCapacityTerminationPolicy; resourceInputs["fleetType"] = state?.fleetType; resourceInputs["iamFleetRole"] = state?.iamFleetRole; resourceInputs["instanceInterruptionBehaviour"] = state?.instanceInterruptionBehaviour; resourceInputs["instancePoolsToUseCount"] = state?.instancePoolsToUseCount; resourceInputs["launchSpecifications"] = state?.launchSpecifications; resourceInputs["launchTemplateConfigs"] = state?.launchTemplateConfigs; resourceInputs["loadBalancers"] = state?.loadBalancers; resourceInputs["onDemandAllocationStrategy"] = state?.onDemandAllocationStrategy; resourceInputs["onDemandMaxTotalPrice"] = state?.onDemandMaxTotalPrice; resourceInputs["onDemandTargetCapacity"] = state?.onDemandTargetCapacity; resourceInputs["region"] = state?.region; resourceInputs["replaceUnhealthyInstances"] = state?.replaceUnhealthyInstances; resourceInputs["spotMaintenanceStrategies"] = state?.spotMaintenanceStrategies; resourceInputs["spotPrice"] = state?.spotPrice; resourceInputs["spotRequestState"] = state?.spotRequestState; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; resourceInputs["targetCapacity"] = state?.targetCapacity; resourceInputs["targetCapacityUnitType"] = state?.targetCapacityUnitType; resourceInputs["targetGroupArns"] = state?.targetGroupArns; resourceInputs["terminateInstancesOnDelete"] = state?.terminateInstancesOnDelete; resourceInputs["terminateInstancesWithExpiration"] = state?.terminateInstancesWithExpiration; resourceInputs["validFrom"] = state?.validFrom; resourceInputs["validUntil"] = state?.validUntil; resourceInputs["waitForFulfillment"] = state?.waitForFulfillment; } else { const args = argsOrState; if (args?.iamFleetRole === undefined && !opts.urn) { throw new Error("Missing required property 'iamFleetRole'"); } if (args?.targetCapacity === undefined && !opts.urn) { throw new Error("Missing required property 'targetCapacity'"); } resourceInputs["allocationStrategy"] = args?.allocationStrategy; resourceInputs["context"] = args?.context; resourceInputs["excessCapacityTerminationPolicy"] = args?.excessCapacityTerminationPolicy; resourceInputs["fleetType"] = args?.fleetType; resourceInputs["iamFleetRole"] = args?.iamFleetRole; resourceInputs["instanceInterruptionBehaviour"] = args?.instanceInterruptionBehaviour; resourceInputs["instancePoolsToUseCount"] = args?.instancePoolsToUseCount; resourceInputs["launchSpecifications"] = args?.launchSpecifications; resourceInputs["launchTemplateConfigs"] = args?.launchTemplateConfigs; resourceInputs["loadBalancers"] = args?.loadBalancers; resourceInputs["onDemandAllocationStrategy"] = args?.onDemandAllocationStrategy; resourceInputs["onDemandMaxTotalPrice"] = args?.onDemandMaxTotalPrice; resourceInputs["onDemandTargetCapacity"] = args?.onDemandTargetCapacity; resourceInputs["region"] = args?.region; resourceInputs["replaceUnhealthyInstances"] = args?.replaceUnhealthyInstances; resourceInputs["spotMaintenanceStrategies"] = args?.spotMaintenanceStrategies; resourceInputs["spotPrice"] = args?.spotPrice; resourceInputs["tags"] = args?.tags; resourceInputs["targetCapacity"] = args?.targetCapacity; resourceInputs["targetCapacityUnitType"] = args?.targetCapacityUnitType; resourceInputs["targetGroupArns"] = args?.targetGroupArns; resourceInputs["terminateInstancesOnDelete"] = args?.terminateInstancesOnDelete; resourceInputs["terminateInstancesWithExpiration"] = args?.terminateInstancesWithExpiration; resourceInputs["validFrom"] = args?.validFrom; resourceInputs["validUntil"] = args?.validUntil; resourceInputs["waitForFulfillment"] = args?.waitForFulfillment; resourceInputs["clientToken"] = undefined /*out*/; resourceInputs["spotRequestState"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(SpotFleetRequest.__pulumiType, name, resourceInputs, opts); } } exports.SpotFleetRequest = SpotFleetRequest; /** @internal */ SpotFleetRequest.__pulumiType = 'aws:ec2/spotFleetRequest:SpotFleetRequest'; //# sourceMappingURL=spotFleetRequest.js.map