/l3/users/slm/2018-12-minsk-aws/student03.BigClassRoom/user :1 :2 :3 :4 :5 :6 :7 |
|
$~
{ } [ ] EOF fi ~ user@instructor:~/aws$ scripts/create-infrastructure.sh Usage: scripts/create-infrastructure.sh start|stop user@instructor:~/aws$ scripts/create-infrastructure.sh start ... user@instructor:~/aws$ git commit -m 'initial revision of create-infrastructure'| push | user@instructor:~/aws$ git commit -m 'initial revision of create-infrastructure'| status | user@instructor:~/aws$ | | user@instructor:~/aws$ user@instructor:~/aws$ user@instructor:~/aws$ exit exit |
$vim scripts/create-infrastructure.sh
|
$aws ec2 run-instance --help
![]() usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters] To see help text, you can run: aws help aws <command> help aws <command> <subcommand> help aws: error: argument operation: Invalid choice, valid choices are: accept-reserved-instances-exchange-quote | accept-transit-gateway-vpc-attachment accept-vpc-endpoint-connections | accept-vpc-peering-connection advertise-byoip-cidr | allocate-address allocate-hosts | apply-security-groups-to-client-vpn-target-network ... search-transit-gateway-routes | start-instances stop-instances | terminate-client-vpn-connections terminate-instances | unassign-ipv6-addresses unassign-private-ip-addresses | unmonitor-instances update-security-group-rule-descriptions-egress | update-security-group-rule-descriptions-ingress withdraw-byoip-cidr | wait help Invalid choice: 'run-instance', maybe you meant: * run-instances * bundle-instance |
$aws ec2 run-instances --help
![]() usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters] To see help text, you can run: aws help aws <command> help aws <command> <subcommand> help Unknown options: --help |
$aws ec2 run-instances help
RUN-INSTANCES() RUN-INSTANCES() NAME run-instances - DESCRIPTION Launches the specified number of instances using an AMI for which you have permissions. You can specify a number of options, or leave the default options. The following rules apply: o [EC2-VPC] If you don't specify a subnet ID, we choose a default sub- net from your default VPC for you. If you don't have a default VPC, you must specify a subnet ID in the request. o [EC2-Classic] If don't specify an Availability Zone, we choose one for you. o Some instance types must be launched into a VPC. If you do not have a default VPC, or if you do not specify a subnet ID, the request fails. For more information, see Instance Types Available Only in a VPC . |
$aws ec2 run-instances help | less -R
|
$vi scripts/create-infrastructure.sh
|
$nano scripts/create-infrastructure.sh
|
$!/bin/bash
![]() vpc_id=vpc-08b950cd8140c7403 key_name=user3 security_group=... shutdown_type=shutdown start() { private_ip_address="10.2.1.31" aws ec2 run-instances \ --image-id "$image_id" \ --instance-type "$instance_type" \ ... [--dry-run | --no-dry-run] [--ebs-optimized | --no-ebs-optimized] [--iam-instance-profile <value>] [--instance-initiated-shutdown-behavior <value>] [--network-interfaces <value>] [--private-ip-address <value>] [--elastic-gpu-specification <value>] ^G Get Help ^O Write Out ^W Where Is ^K Cut Text ^J Justify ^C Cur Pos ^Y Prev Page M-\ First Line Use "fg" to return to nano.le ^\ Replace ^U Uncut Text ^T To Linter ^_ Go To Line ^V Next Page M-/ Last Line [1]+ Stopped nano scripts/create-infrastructure.sh |
$nano scripts/create-infrastructure.sh
|
$vi scripts/create-infrastructure.sh
|
$vi scripts/create-infrastructure.sh
|
$vi scripts/create-infrastructure.sh
|
${
private_ip_address="10.1.1.31" public_ip=associate-public-ip-address aws ec2 run-instances \ --image-id "$image_id" \ --instance-type "$instance_type" \ --key-name "$key_name" \ --subnet_id "$subnet_id" \ --instance-initiated-shutdown-behavior"$shutdown_type" \ --private-ip-address "$private_ip_address" \ --tag-specifications "$tags"] \ ... --tag-specifications ] \ -- : } stop() { : } if [ = start ]; then start |
${
#!/bin/bash image_id=ami-09693313102a30b2c instance_type=t2.micro vpc_id=vpc-08b950cd8140c7403 key_name=user3 shutdown_type=stop "scripts/create-infrastructure.sh" 45L, 783C #!/bin/bash image_id=ami-09693313102a30b2c instance_type=t2.micro ... --tag-specifications "$tags"] \ --${public_ip} : } stop() { : } if [ "$1" = start ]; then start |
$ ))
|
$git status
On branch master Your branch is up-to-date with 'origin/master'. Untracked files: (use "git add <file>..." to include in what will be committed) scripts/ nothing added to commit but untracked files present (use "git add" to track) |
$git add scripts/
|
$git status
On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: scripts/create-infrastructure.sh |
$git commit -m 'initial revision of create-infrastructure'
[master 267fcbb] initial revision of create-infrastructure Committer: ValeryBarai <user@m3.class.sl> Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly: git config --global user.name "Your Name" git config --global user.email you@example.com After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author 1 file changed, 50 insertions(+) create mode 100755 scripts/create-infrastructure.sh |
$git config --global user.name "ValeryBarai"
|
$git push
Username for 'https://github.com': ValeryBarai Password for 'https://ValeryBarai@github.com': Counting objects: 4, done. Delta compression using up to 4 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 908 bytes | 0 bytes/s, done. Total 4 (delta 0), reused 0 (delta 0) To https://github.com/ValeryBarai/AWS.git 4750fbe..267fcbb master -> master |
$exit
![]() exit There are stopped jobs. |
$ssh m0
![]() The authenticity of host 'm0 (172.20.13.183)' can't be established. ECDSA key fingerprint is SHA256:OmAUOGefATc3fUfxoq0a8q0SorClVWEnwAh7KqphL8A. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'm0' (ECDSA) to the list of known hosts. user@m0's password: Linux instructor 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Thu Dec 20 10:18:15 2018 from 172.20.13.191 l3-agent is already running: pid=1843; pidfile=/home/user/.lilalo/l3-agent.pid user@instructor:~$ d -bash: d: command not found user@instructor:~$ logout Connection to m0 closed. |
$ssh m0
user@m0's password: Linux instructor 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Thu Dec 20 10:18:41 2018 from 172.20.13.180 l3-agent is already running: pid=1843; pidfile=/home/user/.lilalo/l3-agent.pid user@instructor:~$ logout Connection to m0 closed. |
$vi scripts/create-infrastructure.sh
|
$vi scripts/create-infrastructure.sh
|
$vi scripts/create-infrastructure.sh
|
$^C
|
$^C
|
$^C
|
$^C
|
$(
SHUTDOWN_TYPE=stop SUBNET_ID=subnet-060d8c5c243f86664 TAGS="ResourceType=instance,Tags=[{Key=installation_id,Value=${USER_NAME}-1},{Key=Name, Value=NAME}]" start_vm() { { local_private_ip_address="$1" local_public_ip_address="$2" local_name="$3" local tags=$(echo $TAGS | sed s/NAME/$name/) #local tags=$(TAGS/NAME/$name} aws ec2 run-instances \ --image-id "$image_id" \ --instance-type "$instance_type" \ --subnet-id "$SUBNET_ID" \ --instance-initiated-shutdown-behavior "$SHUTDOWN_TYPE" \ "scripts/create-infrastructure.sh" 63L, 1608C written |
$rn teacher_script.txt teacher_script_1.txt
bash: rn: command not found |
|