0
# Core Compute Services
1
2
Complete infrastructure services for compute resources including EC2 instances, Auto Scaling, Load Balancing, and related compute infrastructure with 165+ resource types and data sources.
3
4
## Capabilities
5
6
### EC2 Instances
7
8
Create and manage EC2 virtual machines with full configuration options.
9
10
```typescript { .api }
11
/**
12
* Creates an EC2 instance
13
*/
14
class ec2.Instance extends pulumi.CustomResource {
15
constructor(name: string, args: ec2.InstanceArgs, opts?: pulumi.ResourceOptions);
16
17
/** The AMI ID used for the instance */
18
public readonly ami!: pulumi.Output<string>;
19
/** The instance type (e.g., t3.micro, m5.large) */
20
public readonly instanceType!: pulumi.Output<string>;
21
/** The public IP address assigned to the instance */
22
public readonly publicIp!: pulumi.Output<string>;
23
/** The private IP address assigned to the instance */
24
public readonly privateIp!: pulumi.Output<string>;
25
/** The security groups associated with the instance */
26
public readonly securityGroups!: pulumi.Output<string[]>;
27
/** The subnet ID where the instance is launched */
28
public readonly subnetId!: pulumi.Output<string>;
29
/** The VPC ID where the instance is launched */
30
public readonly vpcSecurityGroupIds!: pulumi.Output<string[]>;
31
/** The key pair name for SSH access */
32
public readonly keyName!: pulumi.Output<string>;
33
/** The instance state (running, stopped, etc.) */
34
public readonly instanceState!: pulumi.Output<string>;
35
/** The ARN of the instance */
36
public readonly arn!: pulumi.Output<string>;
37
/** Resource tags */
38
public readonly tags!: pulumi.Output<{[key: string]: string}>;
39
}
40
41
interface ec2.InstanceArgs {
42
/** The AMI to use for the instance */
43
ami: pulumi.Input<string>;
44
/** The instance type */
45
instanceType: pulumi.Input<string>;
46
/** The key pair name */
47
keyName?: pulumi.Input<string>;
48
/** Security groups to assign */
49
securityGroups?: pulumi.Input<pulumi.Input<string>[]>;
50
/** VPC security group IDs */
51
vpcSecurityGroupIds?: pulumi.Input<pulumi.Input<string>[]>;
52
/** Subnet ID to launch in */
53
subnetId?: pulumi.Input<string>;
54
/** User data script */
55
userData?: pulumi.Input<string>;
56
/** Whether to associate a public IP */
57
associatePublicIpAddress?: pulumi.Input<boolean>;
58
/** Root block device configuration */
59
rootBlockDevice?: pulumi.Input<ec2.InstanceRootBlockDevice>;
60
/** Additional EBS block devices */
61
ebsBlockDevices?: pulumi.Input<pulumi.Input<ec2.InstanceEbsBlockDevice>[]>;
62
/** Instance monitoring */
63
monitoring?: pulumi.Input<boolean>;
64
/** IAM instance profile */
65
iamInstanceProfile?: pulumi.Input<string>;
66
/** Resource tags */
67
tags?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
68
}
69
```
70
71
**Usage Example:**
72
73
```typescript
74
import * as aws from "@pulumi/aws";
75
76
// Create an EC2 instance
77
const webServer = new aws.ec2.Instance("web-server", {
78
ami: "ami-0c02fb55956c7d316", // Amazon Linux 2
79
instanceType: "t3.micro",
80
keyName: "my-key-pair",
81
securityGroups: ["web-sg"],
82
userData: `#!/bin/bash
83
yum update -y
84
yum install -y httpd
85
systemctl start httpd
86
systemctl enable httpd`,
87
tags: {
88
Name: "WebServer",
89
Environment: "Production",
90
},
91
});
92
93
// Export the public IP
94
export const publicIp = webServer.publicIp;
95
```
96
97
### VPC (Virtual Private Cloud)
98
99
Create and manage isolated network environments.
100
101
```typescript { .api }
102
/**
103
* Creates a VPC (Virtual Private Cloud)
104
*/
105
class ec2.Vpc extends pulumi.CustomResource {
106
constructor(name: string, args: ec2.VpcArgs, opts?: pulumi.ResourceOptions);
107
108
/** The CIDR block for the VPC */
109
public readonly cidrBlock!: pulumi.Output<string>;
110
/** The VPC ID */
111
public readonly id!: pulumi.Output<string>;
112
/** The ARN of the VPC */
113
public readonly arn!: pulumi.Output<string>;
114
/** Whether DNS hostnames are enabled */
115
public readonly enableDnsHostnames!: pulumi.Output<boolean>;
116
/** Whether DNS support is enabled */
117
public readonly enableDnsSupport!: pulumi.Output<boolean>;
118
/** The main route table ID */
119
public readonly mainRouteTableId!: pulumi.Output<string>;
120
/** The default security group ID */
121
public readonly defaultSecurityGroupId!: pulumi.Output<string>;
122
/** The default network ACL ID */
123
public readonly defaultNetworkAclId!: pulumi.Output<string>;
124
/** Resource tags */
125
public readonly tags!: pulumi.Output<{[key: string]: string}>;
126
}
127
128
interface ec2.VpcArgs {
129
/** The CIDR block for the VPC */
130
cidrBlock: pulumi.Input<string>;
131
/** Enable DNS hostnames */
132
enableDnsHostnames?: pulumi.Input<boolean>;
133
/** Enable DNS support */
134
enableDnsSupport?: pulumi.Input<boolean>;
135
/** The tenancy of instances launched into the VPC */
136
instanceTenancy?: pulumi.Input<string>;
137
/** Assign generated IPv6 CIDR block */
138
assignGeneratedIpv6CidrBlock?: pulumi.Input<boolean>;
139
/** Resource tags */
140
tags?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
141
}
142
```
143
144
### Subnets
145
146
Create and manage network subnets within VPCs.
147
148
```typescript { .api }
149
/**
150
* Creates a subnet within a VPC
151
*/
152
class ec2.Subnet extends pulumi.CustomResource {
153
constructor(name: string, args: ec2.SubnetArgs, opts?: pulumi.ResourceOptions);
154
155
/** The subnet ID */
156
public readonly id!: pulumi.Output<string>;
157
/** The ARN of the subnet */
158
public readonly arn!: pulumi.Output<string>;
159
/** The CIDR block for the subnet */
160
public readonly cidrBlock!: pulumi.Output<string>;
161
/** The VPC ID */
162
public readonly vpcId!: pulumi.Output<string>;
163
/** The availability zone */
164
public readonly availabilityZone!: pulumi.Output<string>;
165
/** Whether instances launched in this subnet get public IP addresses */
166
public readonly mapPublicIpOnLaunch!: pulumi.Output<boolean>;
167
/** Resource tags */
168
public readonly tags!: pulumi.Output<{[key: string]: string}>;
169
}
170
171
interface ec2.SubnetArgs {
172
/** The CIDR block for the subnet */
173
cidrBlock: pulumi.Input<string>;
174
/** The VPC ID */
175
vpcId: pulumi.Input<string>;
176
/** The availability zone */
177
availabilityZone?: pulumi.Input<string>;
178
/** Map public IP on launch */
179
mapPublicIpOnLaunch?: pulumi.Input<boolean>;
180
/** Resource tags */
181
tags?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
182
}
183
```
184
185
### Security Groups
186
187
Create and manage network security groups.
188
189
```typescript { .api }
190
/**
191
* Creates a security group
192
*/
193
class ec2.SecurityGroup extends pulumi.CustomResource {
194
constructor(name: string, args: ec2.SecurityGroupArgs, opts?: pulumi.ResourceOptions);
195
196
/** The security group ID */
197
public readonly id!: pulumi.Output<string>;
198
/** The ARN of the security group */
199
public readonly arn!: pulumi.Output<string>;
200
/** The name of the security group */
201
public readonly name!: pulumi.Output<string>;
202
/** The description of the security group */
203
public readonly description!: pulumi.Output<string>;
204
/** The VPC ID */
205
public readonly vpcId!: pulumi.Output<string>;
206
/** Ingress rules */
207
public readonly ingress!: pulumi.Output<ec2.SecurityGroupIngress[]>;
208
/** Egress rules */
209
public readonly egress!: pulumi.Output<ec2.SecurityGroupEgress[]>;
210
/** Resource tags */
211
public readonly tags!: pulumi.Output<{[key: string]: string}>;
212
}
213
214
interface ec2.SecurityGroupArgs {
215
/** The name of the security group */
216
name?: pulumi.Input<string>;
217
/** The description of the security group */
218
description?: pulumi.Input<string>;
219
/** The VPC ID */
220
vpcId?: pulumi.Input<string>;
221
/** Ingress rules */
222
ingress?: pulumi.Input<pulumi.Input<ec2.SecurityGroupIngress>[]>;
223
/** Egress rules */
224
egress?: pulumi.Input<pulumi.Input<ec2.SecurityGroupEgress>[]>;
225
/** Resource tags */
226
tags?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
227
}
228
```
229
230
### Auto Scaling Groups
231
232
Create and manage auto scaling groups for automatic capacity management.
233
234
```typescript { .api }
235
/**
236
* Creates an Auto Scaling Group
237
*/
238
class autoscaling.Group extends pulumi.CustomResource {
239
constructor(name: string, args: autoscaling.GroupArgs, opts?: pulumi.ResourceOptions);
240
241
/** The ARN of the Auto Scaling Group */
242
public readonly arn!: pulumi.Output<string>;
243
/** The name of the Auto Scaling Group */
244
public readonly name!: pulumi.Output<string>;
245
/** The minimum size of the group */
246
public readonly minSize!: pulumi.Output<number>;
247
/** The maximum size of the group */
248
public readonly maxSize!: pulumi.Output<number>;
249
/** The desired capacity of the group */
250
public readonly desiredCapacity!: pulumi.Output<number>;
251
/** The launch configuration name */
252
public readonly launchConfiguration!: pulumi.Output<string>;
253
/** The VPC zone identifiers */
254
public readonly vpcZoneIdentifiers!: pulumi.Output<string[]>;
255
/** The target group ARNs */
256
public readonly targetGroupArns!: pulumi.Output<string[]>;
257
/** Resource tags */
258
public readonly tags!: pulumi.Output<autoscaling.GroupTag[]>;
259
}
260
261
interface autoscaling.GroupArgs {
262
/** The minimum size of the group */
263
minSize: pulumi.Input<number>;
264
/** The maximum size of the group */
265
maxSize: pulumi.Input<number>;
266
/** The desired capacity of the group */
267
desiredCapacity?: pulumi.Input<number>;
268
/** The launch configuration name */
269
launchConfiguration?: pulumi.Input<string>;
270
/** The launch template specification */
271
launchTemplate?: pulumi.Input<autoscaling.GroupLaunchTemplate>;
272
/** The VPC zone identifiers (subnet IDs) */
273
vpcZoneIdentifiers?: pulumi.Input<pulumi.Input<string>[]>;
274
/** The target group ARNs */
275
targetGroupArns?: pulumi.Input<pulumi.Input<string>[]>;
276
/** Health check type */
277
healthCheckType?: pulumi.Input<string>;
278
/** Health check grace period */
279
healthCheckGracePeriod?: pulumi.Input<number>;
280
/** Resource tags */
281
tags?: pulumi.Input<pulumi.Input<autoscaling.GroupTag>[]>;
282
}
283
```
284
285
### Load Balancers (ALB/NLB)
286
287
Create and manage Application and Network Load Balancers.
288
289
```typescript { .api }
290
/**
291
* Creates an Application Load Balancer
292
*/
293
class lb.LoadBalancer extends pulumi.CustomResource {
294
constructor(name: string, args: lb.LoadBalancerArgs, opts?: pulumi.ResourceOptions);
295
296
/** The ARN of the load balancer */
297
public readonly arn!: pulumi.Output<string>;
298
/** The DNS name of the load balancer */
299
public readonly dnsName!: pulumi.Output<string>;
300
/** The hosted zone ID of the load balancer */
301
public readonly zoneId!: pulumi.Output<string>;
302
/** The name of the load balancer */
303
public readonly name!: pulumi.Output<string>;
304
/** The type of load balancer */
305
public readonly loadBalancerType!: pulumi.Output<string>;
306
/** The scheme of the load balancer */
307
public readonly scheme!: pulumi.Output<string>;
308
/** The subnets associated with the load balancer */
309
public readonly subnets!: pulumi.Output<string[]>;
310
/** The security groups associated with the load balancer */
311
public readonly securityGroups!: pulumi.Output<string[]>;
312
/** Resource tags */
313
public readonly tags!: pulumi.Output<{[key: string]: string}>;
314
}
315
316
interface lb.LoadBalancerArgs {
317
/** The name of the load balancer */
318
name?: pulumi.Input<string>;
319
/** The type of load balancer (application, network, gateway) */
320
loadBalancerType?: pulumi.Input<string>;
321
/** The scheme (internet-facing, internal) */
322
scheme?: pulumi.Input<string>;
323
/** The subnets to attach to the load balancer */
324
subnets?: pulumi.Input<pulumi.Input<string>[]>;
325
/** The security groups to assign to the load balancer */
326
securityGroups?: pulumi.Input<pulumi.Input<string>[]>;
327
/** Enable deletion protection */
328
enableDeletionProtection?: pulumi.Input<boolean>;
329
/** The IP address type */
330
ipAddressType?: pulumi.Input<string>;
331
/** Resource tags */
332
tags?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
333
}
334
```
335
336
### Data Source Functions
337
338
Query existing EC2 and compute resources.
339
340
```typescript { .api }
341
/**
342
* Get information about an EC2 instance
343
*/
344
function ec2.getInstance(args: ec2.GetInstanceArgs): Promise<ec2.GetInstanceResult>;
345
346
/**
347
* Get information about a VPC
348
*/
349
function ec2.getVpc(args?: ec2.GetVpcArgs): Promise<ec2.GetVpcResult>;
350
351
/**
352
* Get information about subnets
353
*/
354
function ec2.getSubnets(args?: ec2.GetSubnetsArgs): Promise<ec2.GetSubnetsResult>;
355
356
/**
357
* Get information about security groups
358
*/
359
function ec2.getSecurityGroups(args?: ec2.GetSecurityGroupsArgs): Promise<ec2.GetSecurityGroupsResult>;
360
361
/**
362
* Get information about AMIs
363
*/
364
function ec2.getAmi(args: ec2.GetAmiArgs): Promise<ec2.GetAmiResult>;
365
366
/**
367
* Get information about availability zones
368
*/
369
function ec2.getAvailabilityZones(args?: ec2.GetAvailabilityZonesArgs): Promise<ec2.GetAvailabilityZonesResult>;
370
```
371
372
## Types
373
374
```typescript { .api }
375
interface ec2.InstanceRootBlockDevice {
376
/** The type of volume */
377
volumeType?: pulumi.Input<string>;
378
/** The size of the volume in GBs */
379
volumeSize?: pulumi.Input<number>;
380
/** Whether the volume should be destroyed on instance termination */
381
deleteOnTermination?: pulumi.Input<boolean>;
382
/** Whether the volume should be encrypted */
383
encrypted?: pulumi.Input<boolean>;
384
/** The ARN of the AWS Key Management Service key */
385
kmsKeyId?: pulumi.Input<string>;
386
/** The IOPS for the volume */
387
iops?: pulumi.Input<number>;
388
/** The throughput for the volume */
389
throughput?: pulumi.Input<number>;
390
/** Resource tags */
391
tags?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
392
}
393
394
interface ec2.InstanceEbsBlockDevice {
395
/** The name of the device to mount */
396
deviceName: pulumi.Input<string>;
397
/** The type of volume */
398
volumeType?: pulumi.Input<string>;
399
/** The size of the volume in GBs */
400
volumeSize?: pulumi.Input<number>;
401
/** Whether the volume should be destroyed on instance termination */
402
deleteOnTermination?: pulumi.Input<boolean>;
403
/** Whether the volume should be encrypted */
404
encrypted?: pulumi.Input<boolean>;
405
/** The ARN of the AWS Key Management Service key */
406
kmsKeyId?: pulumi.Input<string>;
407
/** The snapshot ID to mount */
408
snapshotId?: pulumi.Input<string>;
409
/** The IOPS for the volume */
410
iops?: pulumi.Input<number>;
411
/** The throughput for the volume */
412
throughput?: pulumi.Input<number>;
413
/** Resource tags */
414
tags?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
415
}
416
417
interface ec2.SecurityGroupIngress {
418
/** The start port */
419
fromPort?: pulumi.Input<number>;
420
/** The end port */
421
toPort?: pulumi.Input<number>;
422
/** The protocol */
423
protocol?: pulumi.Input<string>;
424
/** The CIDR blocks */
425
cidr_blocks?: pulumi.Input<pulumi.Input<string>[]>;
426
/** The IPv6 CIDR blocks */
427
ipv6_cidr_blocks?: pulumi.Input<pulumi.Input<string>[]>;
428
/** The security groups */
429
security_groups?: pulumi.Input<pulumi.Input<string>[]>;
430
/** Description of the rule */
431
description?: pulumi.Input<string>;
432
}
433
434
interface ec2.SecurityGroupEgress {
435
/** The start port */
436
fromPort?: pulumi.Input<number>;
437
/** The end port */
438
toPort?: pulumi.Input<number>;
439
/** The protocol */
440
protocol?: pulumi.Input<string>;
441
/** The CIDR blocks */
442
cidr_blocks?: pulumi.Input<pulumi.Input<string>[]>;
443
/** The IPv6 CIDR blocks */
444
ipv6_cidr_blocks?: pulumi.Input<pulumi.Input<string>[]>;
445
/** The security groups */
446
security_groups?: pulumi.Input<pulumi.Input<string>[]>;
447
/** Description of the rule */
448
description?: pulumi.Input<string>;
449
}
450
```