File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { EC2Client , RunInstancesCommand } from '@aws-sdk/client-ec2'
2+ import { buildUserData } from '@eighty4/c2'
3+
4+ const userData = btoa ( await buildUserData ( 'cloud_init' ) )
5+
6+ const command = new RunInstancesCommand ( {
7+ ImageId : 'debian-12-arm64' ,
8+ InstanceType : 't2.micro' ,
9+ MinCount : 1 ,
10+ MaxCount : 1 ,
11+ InstanceName : 'my-instance-name' ,
12+ UserData : userData ,
13+ } )
14+
15+ const output = await new EC2Client ( { } ) . send ( command )
16+ const instance = output . Instances [ 0 ]
17+
18+ console . log ( 'created ec2 instance' , instance . InstanceId , instance . Ipv4Address )
Original file line number Diff line number Diff line change 1+ import { buildUserData } from '@eighty4/c2'
2+ import DigitalOcean from 'dots-wrapper'
3+
4+ if ( ! process . env . DIGITALOCEAN_TOKEN ) {
5+ throw new Error ( 'DIGITALOCEAN_TOKEN env var is required' )
6+ }
7+
8+ const userData = btoa ( await buildUserData ( 'cloud_init' ) )
9+
10+ const client = new DigitalOcean ( {
11+ token : process . env . DIGITALOCEAN_TOKEN ,
12+ } )
13+
14+ await client . droplets . create ( )
Original file line number Diff line number Diff line change 11{
22 "dependencies" : {
3- "@linode/api-v4" : " ^0.138.0"
3+ "@aws-sdk/client-ec2" : " ^3.826.0" ,
4+ "@linode/api-v4" : " ^0.138.0" ,
5+ "dots-wrapper" : " ^3.12.0"
46 }
57}
You can’t perform that action at this time.
0 commit comments