izy.devops
command, use:
curl -o- https://raw.githubusercontent.com/izyware/devops/master/sh/install.sh | bash
~/.aws/config
file with different profiles:
[default]
region = us-east-1role_arn = arn:aws:iam::XXXXX:role/engineer
source_profile = default[profile john]
role_arn = arn:aws:iam::YYYYY:role/marketingsource_profile = default
[profile james]
role_arn = arn:aws:iam::ZZZZ:role/marketingsource_profile = default
This will allow you to pass --profile john
to the CLI.
However, AWS node SDK does not support the profile option. You can always verify the "current user" by:
izyaws.sh userId sts get-caller-identity
Or, from the scripting environment:
const sts = new AWS.STS();
sts.getCallerIdentity((err, data) => {
console.log(err, data);});
To work around this problem, you can use assume role:
izyaws.sh
// full access to AWS services and resources.
{"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow","Action": "*",
"Resource": "*"}
]}
You can then set
export AWSACCESSKEY_ID=
export AWSSECRETACCESS_KEY=export AWSSESSIONTOKEN=
After you are done, be sure to unset the variables by
unset AWSACCESSKEYID AWSSECRETACCESSKEY AWSSESSIONTOKEN
If you need to generate a One Time Password from the cli use
izy.devops "otp?generate" queryObject.secretStrBase32 your_secret
izy.devops "otp?generate" queryObject.secretPath ~/.aws/otpsecretizy.devops "otp?generate" queryObject.secretPath ~/googleAccount1/otpsecret
To create an aws session automatically using the otp feature do
izy.aws "sts?newSession"
You can use the following snippet inside aws-sdk/lib/http/node.js
.
console.log('HTTP_REQUEST', JSON.stringify(httpRequest, null, 2));
var stream = http.request(options, function (httpResp) {console.log('OK-------------------------');
var str = '';
var response = httpResp;response.on('data', function (chunk) {
str += chunk;});
response.on('end', function () {console.log({
success: true,responseText: str,
status: response.statusCode,headers: response.headers
});});
return ;You can access the ssh scripts by the ssh prefix:
izy.devops "ssh?shell" MACHINE_ID
izy.devops "ssh?runx" . "xeyes"izy.devops "ssh?socksproxy" MACHINE_ID
[container] izy.devops "ssh?publishssh" $HOME/vpn 8022
[vpn] izy.devops "ssh?localforward" .[local] izy.devops "ssh?socksproxy" . remote
izy.devops "rsync?download" . "~/Downloads/" ~/izyware/izy-idman-tools/id/x/Desktop/Downloads/izy.devops "rsync?upload" . "~/Downloads/" ~/izyware/izy-idman-tools/id/x/Desktop/Downloads/
izy.devops "rsync?nodesync" ~/plat/p/servers/machine "~/codepath" appnameIf your containers dont have key-pair setup, create the key-pair and push to the remote server:
cd CONTAINER_DIR;
ssh-keygen -f ./id_rsachmod 400 id_rsa*
mv id_rsa* configssh-copy-id -i ./config/id_rsa.pub user@server
Then test it with
izy.devops "ssh?shell .
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'private.pem' are too open.To fix this chmod to
chmod 400 private.pem
One you launch the EC2, you should ssh into the machine. You will be greeted by the automatic setup script. Choose the following configuration options:
sudo passwd username
If you need to make futher changes to the server such as setting up SSO, etc. it can be configured by accessing its Admin Web UI using your Web browser.
client.ovpn
file. Also place the (username, password) pair in the auth-user-pass.txt
.
You can copy the files to your destination client machine by doing
izy.devops "rsync?upload" . "PATH/servers/vpn-serverid/" clientmachinepath/servers/vpn-serverid
Use the following command:
izy.devops "openvpn?connect" . SUDO_PASSWORD
Note that the client will need sudo to get on the vpn.
--device /dev/net/tun
If you are using an earlier version, you'll have to run it in privileged mode.
To make sure that the DNS will always work, you should make sure that your DNS server is routed through the eth0 interface. For this reason always use the utilities provided in the ~/vpn folder:
~/vpn_connect.sh connectionfile.ovpn
OR~/vpnconnectsocks.sh connectionfile.ovpn
~/vpn_disconnect.sh
The VPN server will be sending commands to setup the tun interface devices. You should check the client output for:/sbin/ifconfig utun...
Then on the container check the routing config and the utun devices:
ifconfig
netstat -rn and make sure that the tun interface is recieving traffic.Then try connecting to a known IP address without using the DNS:
nc -v myserviceip myserviceport
The test the DNS,
cat /etc/resolv.conf
host izyware.comTo get the IP address for the VPN network interface, do
VPNSERVICEIP=ifconfig | grep 172 | awk -F'[: ]+' '{ print $3 }'
Then use SSH
ssh -v -o StrictHostKeyChecking=no -ND "*:19009" test@$VPNSERVICEIP
debug1: Connection to port LOCALPORT forwarding to socks port 0 requested.
debug2: fd 6 setting TCP_NODELAYdebug2: fd 6 setting O_NONBLOCK
debug3: fd 6 is O_NONBLOCKdebug1: channel 2: new [dynamic-tcpip]
debug2: channel 2: pre_dynamic: have 0debug2: channel 2: pre_dynamic: have 3
debug2: channel 2: decode socks5debug2: channel 2: socks5 auth done
debug2: channel 2: pre_dynamic: need moredebug2: channel 2: pre_dynamic: have 0
debug2: channel 2: pre_dynamic: have 10debug2: channel 2: decode socks5
debug2: channel 2: socks5 post authdebug2: channel 2: only socks5 connect supported
However, successful connections would have resulted in ()
debug2: channel 8: dynamic request: socks5 host IP port 443 command 1
The reason is openSSH does not support "UDP ASSOCIATE" (only "SSHSOCKS5CONNECT"). See rfc1928 for more details.
To address this issue, either use protoco TCP (you would need to do the same for using http proxy because proxying is only supported for the TCP protocol). i.e. to have TCP enabled for your openVPN server:
/etc/openvpn/server.conf
/var/log/syslogservice openvpn status
service openvpn restart As an alternative, you may use vendors that are SOCKS5 compliant. We recommend dante:git clone https://github.com/wernight/docker-dante
sudo docker build --rm -t izyidman_dante . sudo docker run -d -p 1080:1080 izyidman_danteizy.aws "codebuild?check" queryObject.izyUser 86 queryObject.showLogs true queryObject.projectName myProject
Exploring codebuild setup and viewing a build projects details
npm run codebuild.projectDetails queryObject.izyUser 86 queryObject.projectName myProject
To debug your code build scripts (buildspec.*) use the provided docker Image:
docker build -f codebuild/Dockerfile -t izy-aws-codebuild:7.0 .;
You can then shell into the environment and run your commands:
docker run -e BUILDDIR=pwd
--env-file ~/dockerenv-file.list -v /var/run/docker.sock:/var/run/docker.sock -v pwd
:/sourcedirectory -it --entrypoint sh izy-aws-codebuild:7.0 -c bash;
dockershell>killanddeletedata.sh imagekeyword (i.e. sql)
Notice that if you dont have a env file or AWS credentials are not available as environment variables you share your .aws folder:
-v echo ~/.aws
:/root/.aws
If your application generates or uses docker containers as part of its CICD, you will need to use privilaged mode inside codebuild. Notice that the filesystem/volume mapping and network interfaces addresses can get confusing in this case. The most common issue reported on MacOS platforms vs Linux (Codebuild) is that the docker-compose volume mapping (using the volumes block) on Mac will only work if full path to host operating system is provided. Therefore, it is recommended to use the BUILD_DIR
variable. The other common issue reported for MacOS is that passing environment variables with newline from MacOS to the container environment will endup converting the newlines to "\n" string which could be a problem. If your code relies on environment variables for file generation, you should take this into account and convert "\n" to new line (for example by using awk or sed).
ENV CONTAINER_CONTEXT: Service Probe
ENV SLEEP_SECONDS: 5ENV CMDTORUN: /usr/bin/nc -vz localhost 3306
You can launch dockerized browser instances using the following options:use docker-firefox container image:
izy.devops "docker?firefox" .
The following are the recommended customization for maximum security and interoperability:
about:config > clipboard
and set all the flags to true.about:config > general.useragent.override
about:settings > socks
* Also set network.proxy.socksremotedns
, otherwise some DNS lookups may fail
privacy.resistFingerprinting
will not address the timezone issue and it will break the useragent customization.izy.devops "docker?chrome" .
If you need to shell into the container to test networking, etc.
docker run -it --entrypoint sh --name=firefox -p 5800:5800 -v folder_mapping jlesage/firefox -c sh
Deep clone the app directory:
rsync -rv apps/static-website/ myfolder
cd myfolder; Update the variables (domain, aws credentials, etc.) inside thevi terraform_config.sh
Make sure that you dont use the naked (apex) domain name and use a prefix (www, etc.). DNS protocol does not support CNAME records or 301 redirects for the apex record. See the section regarding AWS Quirks below to learn how to redirect the apex to your subdomain (domain -> www.domain).
Shell into the image:
docker run -v pwd
:/izyhostdir -it --entrypoint sh hashicorp/terraform:latest
Once inside the image, do:
clear; cd /izyhostdir; source ./terraform_config.sh; terraform apply -auto-approve;
The output should print the list of environment variables that will be used below:
export AWSCLOUDFRONTDISTRIBUTIONDOMAINNAME=GRABFROMTERRAFORM_OUTPUT;
export AWSCLOUDFRONTDISTRIBUTIONID=GRABFROMTERRAFORMOUTPUT;export AWSS3BUCKETID=GRABFROMTERRAFORMOUTPUT;
You can push your files to the s3 bucket:
izyaws.sh
Make sure to invalidate the cloudfront distribution after the push
izyaws.sh
* when this is being created for the firsttime, you might get a "Missing required argument" error, followed by The argument "origin.0.domain_name" is required, but no definition was found.
. rerunning the plan will address this.
deleteall.sh
If you have a stateful container (i.e. mysql), you should stop and delete its state by
killanddeletedata.sh grepStr (mysql)
To build runtimes
docker build -f dockertools/nodejs/Dockerfile -t izy-nodejs:16.0 .;
docker run -it --entrypoint sh izy-nodejs:16.0 -c bash;* customers reported EACCES: permission denied on Ubuntu
* useful for headless and automation environments
* useful for exploring codebuild setup and viewing a build projects details in AWS CodeBuild
* utilize callpretty for better output* add verbose logging
dante: https://github.com/wernight/docker-dante
docker-firefox: https://github.com/jlesage/docker-firefoxdocker-chrome: https://github.com/kasmtech/workspaces-images
github: https://github.com/izyware/devops