Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getCluster(): CloudCluster | undefined {
// If no ECS cluster has been initialized, see if we must lazily allocate one.
if (!cluster) {
if (config.ecsAutoCluster) {
// Translate the comma-seperated list into an array or undefined.
let instanceRolePolicyARNs;
if (config.ecsAutoClusterInstanceRolePolicyARNs) {
instanceRolePolicyARNs = (config.ecsAutoClusterInstanceRolePolicyARNs || "").split(",");
}
// If we are asked to provision a cluster, then we will have created a network
// above - create a cluster in that network.
cluster = new awsx.Cluster(createNameWithStackInfo("global"), {
network: getOrCreateNetwork(),
addEFS: config.ecsAutoClusterUseEFS,
instanceType: config.ecsAutoClusterInstanceType,
instanceRolePolicyARNs: instanceRolePolicyARNs,
instanceRootVolumeSize: config.ecsAutoClusterInstanceRootVolumeSize,
instanceDockerImageVolumeSize: config.ecsAutoClusterInstanceDockerImageVolumeSize,
instanceSwapVolumeSize: config.ecsAutoClusterInstanceSwapVolumeSize,
minSize: config.ecsAutoClusterMinSize,
maxSize: config.ecsAutoClusterMaxSize,
publicKey: config.ecsAutoClusterPublicKey,
});
} else if (config.ecsClusterARN) {
// Else if we have an externally provided cluster and can use that.
cluster = {
ecsClusterARN: pulumi.output(config.ecsClusterARN),
securityGroupId: config.ecsClusterSecurityGroup
// limitations under the License.
import * as awsx from "@pulumi/awsx";
import * as pulumi from "@pulumi/pulumi";
import { Output } from "@pulumi/pulumi";
const prefix = "infratest";
const numAvailabilityZones = 2;
const instanceType = "m5.large";
let network = new awsx.Network(`${prefix}-net`, {
numberOfAvailabilityZones: numAvailabilityZones, // Create subnets in many AZs
usePrivateSubnets: true, // Run compute inside private subnets in each AZ
});
const cluster = new awsx.Cluster(prefix, {
minSize: numAvailabilityZones, // Ensure we keep at least one VM per AZ
network: network, // The network to provision this cluster inside
addEFS: false, // Don't provision an EFS file system for this cluster
instanceType: instanceType, // Use a configured value for cluster VM sizes
});
// Export details of the network and cluster
export let vpcId = network.vpcId;
export let privateSubnetIds = pulumi.all(network.subnetIds).apply(ids => ids.join(","));
export let publicSubnetIds = pulumi.all(network.publicSubnetIds).apply(ids => ids.join(","));
export let securityGroupIds = pulumi.all(network.securityGroupIds).apply(ids => ids.join(","));
export let ecsClusterARN = cluster.ecsClusterARN;
export let ecsClusterSecurityGroup = cluster.securityGroupId;