1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
|
%global _empty_manifest_terminate_build 0
Name: python-cdk-spot-one
Version: 2.0.328
Release: 1
Summary: One spot instance with EIP and defined duration. No interruption.
License: Apache-2.0
URL: https://github.com/pahud/cdk-spot-one.git
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/3a/f0/bcd0f1f43e4a29ad96a271b3beefb8ba64e0cbb1f19ac9397009553ce687/cdk-spot-one-2.0.328.tar.gz
BuildArch: noarch
Requires: python3-aws-cdk-lib
Requires: python3-constructs
Requires: python3-jsii
Requires: python3-publication
Requires: python3-typeguard
%description
[](https://badge.fury.io/js/cdk-spot-one)
[](https://badge.fury.io/py/cdk-spot-one)

# cdk-spot-one
One spot instance with EIP and defined duration. No interruption.
# Install
Use the npm dist tag to opt in CDKv1 or CDKv2:
```sh
// for CDKv2
npm install cdk-spot-one
or
npm install cdk-spot-one@latest
// for CDKv1
npm install cdk-spot-one@cdkv1
```
# Why
Sometimes we need an Amazon EC2 instance with static fixed IP for testing or development purpose for a duration of
time(probably hours). We need to make sure during this time, no interruption will occur and we don't want to pay
for on-demand rate. `cdk-spot-one` helps you reserve one single spot instance with pre-allocated or new
Elastic IP addresses(EIP) with defined `blockDuration`, during which time the spot instance will be secured with no spot interruption.
Behind the scene, `cdk-spot-one` provisions a spot fleet with capacity of single instance for you and it associates the EIP with this instance. The spot fleet is reserved as spot block with `blockDuration` from one hour up to six hours to ensure the high availability for your spot instance.
Multiple spot instances are possible by simply specifying the `targetCapacity` construct property, but we only associate the EIP with the first spot instance at this moment.
Enjoy your highly durable one spot instance with AWS CDK!
# Constructs
This library provides two major constructs:
## SpotInstance
* Create a spot instance **without** any fleet
* Does **NOT** support [Spot Block](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html#fixed-duration-spot-instances)
* Support `stop` or `hibernate` instance
Scenario: To leverage the `stop` or `hibernate` capabilities of the spot instance to persist the data in the ebs volume.
## SpotFleet
* Create a spot instance with a [Spot Fleet](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet.html)
* Support [Spot Block](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html#fixed-duration-spot-instances)
* Does **NOT** support `stop` or `hibernate` instance
Scenario: To ensure the availability with no disruption with defined period up to 6 hours.
# Sample
## SpotInstance
```python
import { SpotInstance, AmazonMachineImage } from 'cdk-spot-one';
// Default use Amazon Linux 2
new SpotInstance(stack, 'SpotInstance');
// Custom Id use Ubuntu 20.04 Arm64 Server.
new SpotInstance(stack, 'SpotInstanceUbuntu', {
vpc,
customAmiId: AmazonMachineImage.UBUNTU_20_04_ARM64.getImage(stack).imageId,
defaultInstanceType: new InstanceType('t4g.medium'),
keyName,
blockDeviceMappings: [{ deviceName: '/dev/sda1', ebs: { volumeSize: 20 } }],
additionalUserData: ['curl -fsSL https://get.docker.com -o get-docker.sh', 'sudo sh get-docker.sh'],
});
```
## SpotFleet
```python
import { SpotFleet } from 'cdk-spot-one';
// create the first fleet for one hour and associate with our existing EIP
const fleet = new SpotFleet(stack, 'SpotFleet')
// configure the expiration after 1 hour
fleet.expireAfter(Duration.hours(1))
// create the 2nd fleet with single Gravition 2 instance for 6 hours and associate with new EIP
const fleet2 = new SpotFleet(stack, 'SpotFleet2', {
blockDuration: BlockDuration.SIX_HOURS,
eipAllocationId: 'eipalloc-0d1bc6d85895a5410',
defaultInstanceType: new InstanceType('c6g.large'),
vpc: fleet.vpc,
})
// configure the expiration after 6 hours
fleet2.expireAfter(Duration.hours(6))
// print the instanceId from each spot fleet
new CfnOutput(stack, 'SpotFleetInstanceId', { value: fleet.instanceId })
new CfnOutput(stack, 'SpotFleet2InstanceId', { value: fleet2.instanceId })
```
# Create spot instances without duration block
```python
const fleet = new SpotFleet(stack, 'SpotFleet', {
blockDuration: BlockDuration.NONE,
})
```
NOTE: This kind of spot instance will be interrupted by AWS. However the fleet is using type [maintain](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet.html#spot-fleet-allocation-strategy), the fleet can be refulfilled.
# ARM64 and Graviton 2 support
`cdk-spot-one` selects the latest Amazon Linux 2 AMI for your `ARM64` instances. Simply select the instance types with the `defaultInstanceType` property and the `SpotFleet` will auto configure correct AMI for the instance.
```python
defaultInstanceType: new InstanceType('c6g.large')
```
# ECS Cluster support
See https://github.com/pahud/cdk-spot-one/issues/270#issuecomment-877152685
# Connect with Session Manager(recommended)
You may connect to the spot instance with [Session Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-sessions-start.html).
```sh
# make sure you have installed session-manager-plugin
$ session-manager-plugin
# start session
$ aws ssm start-session --target INSTANCE_ID
```
# Connect with EC2 SSH Connect
By default the `cdk-spot-one` does not bind any SSH public key for you on the instance. You are encouraged to use `ec2-instance-connect` to send your public key from local followed by one-time SSH connect.
For example:
```sh
pubkey="$HOME/.ssh/aws_2020_id_rsa.pub"
echo "sending public key to ${instanceId}"
aws ec2-instance-connect send-ssh-public-key --instance-id ${instanceId} --instance-os-user ec2-user \
--ssh-public-key file://${pubkey} --availability-zone ${az}
```
## npx ec2-connect INSTANCE_ID
To connect to the instance, run `npx ec2-connect` as below:
```sh
$ npx ec2-connect i-01f827ab9de7b93a9
```
or
```sh
$ npx ec2-connect i-01f827ab9de7b93a9 ~/.ssh/other_public_key_path
```
If you are using different SSH public key(default is ~/.ssh/id_rsa.pub)
%package -n python3-cdk-spot-one
Summary: One spot instance with EIP and defined duration. No interruption.
Provides: python-cdk-spot-one
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-cdk-spot-one
[](https://badge.fury.io/js/cdk-spot-one)
[](https://badge.fury.io/py/cdk-spot-one)

# cdk-spot-one
One spot instance with EIP and defined duration. No interruption.
# Install
Use the npm dist tag to opt in CDKv1 or CDKv2:
```sh
// for CDKv2
npm install cdk-spot-one
or
npm install cdk-spot-one@latest
// for CDKv1
npm install cdk-spot-one@cdkv1
```
# Why
Sometimes we need an Amazon EC2 instance with static fixed IP for testing or development purpose for a duration of
time(probably hours). We need to make sure during this time, no interruption will occur and we don't want to pay
for on-demand rate. `cdk-spot-one` helps you reserve one single spot instance with pre-allocated or new
Elastic IP addresses(EIP) with defined `blockDuration`, during which time the spot instance will be secured with no spot interruption.
Behind the scene, `cdk-spot-one` provisions a spot fleet with capacity of single instance for you and it associates the EIP with this instance. The spot fleet is reserved as spot block with `blockDuration` from one hour up to six hours to ensure the high availability for your spot instance.
Multiple spot instances are possible by simply specifying the `targetCapacity` construct property, but we only associate the EIP with the first spot instance at this moment.
Enjoy your highly durable one spot instance with AWS CDK!
# Constructs
This library provides two major constructs:
## SpotInstance
* Create a spot instance **without** any fleet
* Does **NOT** support [Spot Block](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html#fixed-duration-spot-instances)
* Support `stop` or `hibernate` instance
Scenario: To leverage the `stop` or `hibernate` capabilities of the spot instance to persist the data in the ebs volume.
## SpotFleet
* Create a spot instance with a [Spot Fleet](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet.html)
* Support [Spot Block](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html#fixed-duration-spot-instances)
* Does **NOT** support `stop` or `hibernate` instance
Scenario: To ensure the availability with no disruption with defined period up to 6 hours.
# Sample
## SpotInstance
```python
import { SpotInstance, AmazonMachineImage } from 'cdk-spot-one';
// Default use Amazon Linux 2
new SpotInstance(stack, 'SpotInstance');
// Custom Id use Ubuntu 20.04 Arm64 Server.
new SpotInstance(stack, 'SpotInstanceUbuntu', {
vpc,
customAmiId: AmazonMachineImage.UBUNTU_20_04_ARM64.getImage(stack).imageId,
defaultInstanceType: new InstanceType('t4g.medium'),
keyName,
blockDeviceMappings: [{ deviceName: '/dev/sda1', ebs: { volumeSize: 20 } }],
additionalUserData: ['curl -fsSL https://get.docker.com -o get-docker.sh', 'sudo sh get-docker.sh'],
});
```
## SpotFleet
```python
import { SpotFleet } from 'cdk-spot-one';
// create the first fleet for one hour and associate with our existing EIP
const fleet = new SpotFleet(stack, 'SpotFleet')
// configure the expiration after 1 hour
fleet.expireAfter(Duration.hours(1))
// create the 2nd fleet with single Gravition 2 instance for 6 hours and associate with new EIP
const fleet2 = new SpotFleet(stack, 'SpotFleet2', {
blockDuration: BlockDuration.SIX_HOURS,
eipAllocationId: 'eipalloc-0d1bc6d85895a5410',
defaultInstanceType: new InstanceType('c6g.large'),
vpc: fleet.vpc,
})
// configure the expiration after 6 hours
fleet2.expireAfter(Duration.hours(6))
// print the instanceId from each spot fleet
new CfnOutput(stack, 'SpotFleetInstanceId', { value: fleet.instanceId })
new CfnOutput(stack, 'SpotFleet2InstanceId', { value: fleet2.instanceId })
```
# Create spot instances without duration block
```python
const fleet = new SpotFleet(stack, 'SpotFleet', {
blockDuration: BlockDuration.NONE,
})
```
NOTE: This kind of spot instance will be interrupted by AWS. However the fleet is using type [maintain](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet.html#spot-fleet-allocation-strategy), the fleet can be refulfilled.
# ARM64 and Graviton 2 support
`cdk-spot-one` selects the latest Amazon Linux 2 AMI for your `ARM64` instances. Simply select the instance types with the `defaultInstanceType` property and the `SpotFleet` will auto configure correct AMI for the instance.
```python
defaultInstanceType: new InstanceType('c6g.large')
```
# ECS Cluster support
See https://github.com/pahud/cdk-spot-one/issues/270#issuecomment-877152685
# Connect with Session Manager(recommended)
You may connect to the spot instance with [Session Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-sessions-start.html).
```sh
# make sure you have installed session-manager-plugin
$ session-manager-plugin
# start session
$ aws ssm start-session --target INSTANCE_ID
```
# Connect with EC2 SSH Connect
By default the `cdk-spot-one` does not bind any SSH public key for you on the instance. You are encouraged to use `ec2-instance-connect` to send your public key from local followed by one-time SSH connect.
For example:
```sh
pubkey="$HOME/.ssh/aws_2020_id_rsa.pub"
echo "sending public key to ${instanceId}"
aws ec2-instance-connect send-ssh-public-key --instance-id ${instanceId} --instance-os-user ec2-user \
--ssh-public-key file://${pubkey} --availability-zone ${az}
```
## npx ec2-connect INSTANCE_ID
To connect to the instance, run `npx ec2-connect` as below:
```sh
$ npx ec2-connect i-01f827ab9de7b93a9
```
or
```sh
$ npx ec2-connect i-01f827ab9de7b93a9 ~/.ssh/other_public_key_path
```
If you are using different SSH public key(default is ~/.ssh/id_rsa.pub)
%package help
Summary: Development documents and examples for cdk-spot-one
Provides: python3-cdk-spot-one-doc
%description help
[](https://badge.fury.io/js/cdk-spot-one)
[](https://badge.fury.io/py/cdk-spot-one)

# cdk-spot-one
One spot instance with EIP and defined duration. No interruption.
# Install
Use the npm dist tag to opt in CDKv1 or CDKv2:
```sh
// for CDKv2
npm install cdk-spot-one
or
npm install cdk-spot-one@latest
// for CDKv1
npm install cdk-spot-one@cdkv1
```
# Why
Sometimes we need an Amazon EC2 instance with static fixed IP for testing or development purpose for a duration of
time(probably hours). We need to make sure during this time, no interruption will occur and we don't want to pay
for on-demand rate. `cdk-spot-one` helps you reserve one single spot instance with pre-allocated or new
Elastic IP addresses(EIP) with defined `blockDuration`, during which time the spot instance will be secured with no spot interruption.
Behind the scene, `cdk-spot-one` provisions a spot fleet with capacity of single instance for you and it associates the EIP with this instance. The spot fleet is reserved as spot block with `blockDuration` from one hour up to six hours to ensure the high availability for your spot instance.
Multiple spot instances are possible by simply specifying the `targetCapacity` construct property, but we only associate the EIP with the first spot instance at this moment.
Enjoy your highly durable one spot instance with AWS CDK!
# Constructs
This library provides two major constructs:
## SpotInstance
* Create a spot instance **without** any fleet
* Does **NOT** support [Spot Block](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html#fixed-duration-spot-instances)
* Support `stop` or `hibernate` instance
Scenario: To leverage the `stop` or `hibernate` capabilities of the spot instance to persist the data in the ebs volume.
## SpotFleet
* Create a spot instance with a [Spot Fleet](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet.html)
* Support [Spot Block](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html#fixed-duration-spot-instances)
* Does **NOT** support `stop` or `hibernate` instance
Scenario: To ensure the availability with no disruption with defined period up to 6 hours.
# Sample
## SpotInstance
```python
import { SpotInstance, AmazonMachineImage } from 'cdk-spot-one';
// Default use Amazon Linux 2
new SpotInstance(stack, 'SpotInstance');
// Custom Id use Ubuntu 20.04 Arm64 Server.
new SpotInstance(stack, 'SpotInstanceUbuntu', {
vpc,
customAmiId: AmazonMachineImage.UBUNTU_20_04_ARM64.getImage(stack).imageId,
defaultInstanceType: new InstanceType('t4g.medium'),
keyName,
blockDeviceMappings: [{ deviceName: '/dev/sda1', ebs: { volumeSize: 20 } }],
additionalUserData: ['curl -fsSL https://get.docker.com -o get-docker.sh', 'sudo sh get-docker.sh'],
});
```
## SpotFleet
```python
import { SpotFleet } from 'cdk-spot-one';
// create the first fleet for one hour and associate with our existing EIP
const fleet = new SpotFleet(stack, 'SpotFleet')
// configure the expiration after 1 hour
fleet.expireAfter(Duration.hours(1))
// create the 2nd fleet with single Gravition 2 instance for 6 hours and associate with new EIP
const fleet2 = new SpotFleet(stack, 'SpotFleet2', {
blockDuration: BlockDuration.SIX_HOURS,
eipAllocationId: 'eipalloc-0d1bc6d85895a5410',
defaultInstanceType: new InstanceType('c6g.large'),
vpc: fleet.vpc,
})
// configure the expiration after 6 hours
fleet2.expireAfter(Duration.hours(6))
// print the instanceId from each spot fleet
new CfnOutput(stack, 'SpotFleetInstanceId', { value: fleet.instanceId })
new CfnOutput(stack, 'SpotFleet2InstanceId', { value: fleet2.instanceId })
```
# Create spot instances without duration block
```python
const fleet = new SpotFleet(stack, 'SpotFleet', {
blockDuration: BlockDuration.NONE,
})
```
NOTE: This kind of spot instance will be interrupted by AWS. However the fleet is using type [maintain](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet.html#spot-fleet-allocation-strategy), the fleet can be refulfilled.
# ARM64 and Graviton 2 support
`cdk-spot-one` selects the latest Amazon Linux 2 AMI for your `ARM64` instances. Simply select the instance types with the `defaultInstanceType` property and the `SpotFleet` will auto configure correct AMI for the instance.
```python
defaultInstanceType: new InstanceType('c6g.large')
```
# ECS Cluster support
See https://github.com/pahud/cdk-spot-one/issues/270#issuecomment-877152685
# Connect with Session Manager(recommended)
You may connect to the spot instance with [Session Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-sessions-start.html).
```sh
# make sure you have installed session-manager-plugin
$ session-manager-plugin
# start session
$ aws ssm start-session --target INSTANCE_ID
```
# Connect with EC2 SSH Connect
By default the `cdk-spot-one` does not bind any SSH public key for you on the instance. You are encouraged to use `ec2-instance-connect` to send your public key from local followed by one-time SSH connect.
For example:
```sh
pubkey="$HOME/.ssh/aws_2020_id_rsa.pub"
echo "sending public key to ${instanceId}"
aws ec2-instance-connect send-ssh-public-key --instance-id ${instanceId} --instance-os-user ec2-user \
--ssh-public-key file://${pubkey} --availability-zone ${az}
```
## npx ec2-connect INSTANCE_ID
To connect to the instance, run `npx ec2-connect` as below:
```sh
$ npx ec2-connect i-01f827ab9de7b93a9
```
or
```sh
$ npx ec2-connect i-01f827ab9de7b93a9 ~/.ssh/other_public_key_path
```
If you are using different SSH public key(default is ~/.ssh/id_rsa.pub)
%prep
%autosetup -n cdk-spot-one-2.0.328
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-cdk-spot-one -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Sun Apr 23 2023 Python_Bot <Python_Bot@openeuler.org> - 2.0.328-1
- Package Spec generated
|