aws-samples / rancher-on-aws-workshop

Learn how to easily deploy and manage Kubernetes with Rancher on AWS Cloud
https://catalog.workshops.aws/rancher
MIT License
12 stars 4 forks source link

shell vars don't work in cloud9 #28

Closed evdevr closed 1 year ago

evdevr commented 1 year ago

env-setup.sh does not work in cloud9 environment. permissions missing to get IAM role/user. export commands not actually exporting to environment for use in envsubst. As a result there are errors because fields in the eksctl-cluster-actual.yaml are blank. (below env-setup.1.sh is a copy i made without the installs to try to get exporting to work)

Admin:~/environment $ envsubst < ~/eksctl-cluster.yml > ~/eksctl-cluster-actual.yml
bash: /home/ec2-user/eksctl-cluster.yml: No such file or directory
Admin:~/environment $ eksctl create cluster -f eksctl-cluster-actual.yml ; eksctl create iamidentitymapping --cluster $EKS_CLUSTER_NAME --region=$AWS_REGION --arn $rancherUser --group system:masters --username rancher^C
Admin:~/environment $ envsubst < eksctl-cluster.yml > eksctl-cluster-actual.yml
Admin:~/environment $ eksctl create cluster -f eksctl-cluster-actual.yml ; eksctl create iamidentitymapping --cluster $EKS_CLUSTER_NAME --region=$AWS_REGION --arn $rancherUser --group system:masters --username rancher
Error: metadata.name must be set
Error: --cluster=--region= and argument system:masters cannot be used at the same time
Admin:~/environment $ env
NVM_INC=/home/ec2-user/.nvm/versions/node/v16.20.0/include/node
XDG_SESSION_ID=2
HOSTNAME=ip-172-31-40-124.ec2.internal
rvm_bin_path=/home/ec2-user/.rvm/bin
GEM_HOME=/home/ec2-user/.rvm/gems/ruby-2.6.3
NVM_CD_FLAGS=
SHELL=/bin/bash
TERM=xterm-256color
HISTSIZE=100000
IRBRC=/home/ec2-user/.rvm/rubies/ruby-2.6.3/.irbrc
SSH_CLIENT=35.172.155.194 6631 22
ISOUTPUTPANE=0
C9_PORT=8080
OLDPWD=/home/ec2-user
MY_RUBY_HOME=/home/ec2-user/.rvm/rubies/ruby-2.6.3
HISTFILESIZE=100000
NVM_DIR=/home/ec2-user/.nvm
USER=ec2-user
LS_COLORS=rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:
rvm_path=/home/ec2-user/.rvm
TMUX=/tmp/tmux-1000/cloud92.2,5342,1
rvm_prefix=/home/ec2-user
MAIL=/var/spool/mail/ec2-user
PATH=/home/ec2-user/.rvm/gems/ruby-2.6.3/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3@global/bin:/home/ec2-user/.rvm/rubies/ruby-2.6.3/bin:/home/ec2-user/.nvm/versions/node/v16.20.0/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3@global/bin:/home/ec2-user/.rvm/rubies/ruby-2.6.3/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3@global/bin:/home/ec2-user/.rvm/rubies/ruby-2.6.3/bin:/usr/local/bin:/usr/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/usr/local/bin:/home/ec2-user/.rvm/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/usr/local/bin:/home/ec2-user/.rvm/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/usr/local/bin:/home/ec2-user/.rvm/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin
C9_USER=Admin
HGUSER=Admin
PWD=/home/ec2-user/environment
EDITOR=
LANG=en_US.UTF-8
NODE_PATH=/home/ec2-user/.c9/node_modules
TMUX_PANE=%1
HISTCONTROL=ignoredups
rvm_version=1.29.8 (1.29.8)
HOME=/home/ec2-user
SHLVL=5
C9_PID=8052f845ae6f4bc8888d783afdde1b2f
C9_PROJECT=AWS-RGS-Workshop
LOGNAME=ec2-user
GEM_PATH=/home/ec2-user/.rvm/gems/ruby-2.6.3:/home/ec2-user/.rvm/gems/ruby-2.6.3@global
SSH_CONNECTION=35.172.155.194 6631 172.31.40.124 22
LESSOPEN=||/usr/bin/lesspipe.sh %s
NVM_BIN=/home/ec2-user/.nvm/versions/node/v16.20.0/bin
PROMPT_COMMAND=history -a;
PORT=8080
XDG_RUNTIME_DIR=/run/user/1000
IP=127.0.0.1
C9_HOSTNAME=184.72.153.49
RUBY_VERSION=ruby-2.6.3
_=/usr/bin/env
Admin:~/environment $ env | grep AWS
C9_PROJECT=AWS-RGS-Workshop
Admin:~/environment $ ./env-setup.
env-setup.1.sh  env-setup.sh    
Admin:~/environment $ ./env-setup.1.sh 
================ Set some ENV variables =================

An error occurred (AccessDenied) when calling the ListRoles operation: User: arn:aws:sts::019759562784:assumed-role/rancher-manager-stack-EKSCTLRole-D78Q8FNL2T9B/i-0d9daf0baeff2d308 is not authorized to perform: iam:ListRoles on resource: arn:aws:iam::019759562784:role/ because no identity-based policy allows the iam:ListRoles action

An error occurred (AccessDenied) when calling the ListRoles operation: User: arn:aws:sts::019759562784:assumed-role/rancher-manager-stack-EKSCTLRole-D78Q8FNL2T9B/i-0d9daf0baeff2d308 is not authorized to perform: iam:ListRoles on resource: arn:aws:iam::019759562784:role/ because no identity-based policy allows the iam:ListRoles action

An error occurred (AccessDenied) when calling the GetUser operation: User: arn:aws:sts::019759562784:assumed-role/rancher-manager-stack-EKSCTLRole-D78Q8FNL2T9B/i-0d9daf0baeff2d308 is not authorized to perform: iam:GetUser on resource: user rancher-cloud-credential-user because no identity-based policy allows the iam:GetUser action
Admin:~/environment $ env
NVM_INC=/home/ec2-user/.nvm/versions/node/v16.20.0/include/node
XDG_SESSION_ID=2
HOSTNAME=ip-172-31-40-124.ec2.internal
rvm_bin_path=/home/ec2-user/.rvm/bin
GEM_HOME=/home/ec2-user/.rvm/gems/ruby-2.6.3
NVM_CD_FLAGS=
SHELL=/bin/bash
TERM=xterm-256color
HISTSIZE=100000
IRBRC=/home/ec2-user/.rvm/rubies/ruby-2.6.3/.irbrc
SSH_CLIENT=35.172.155.194 6631 22
ISOUTPUTPANE=0
C9_PORT=8080
OLDPWD=/home/ec2-user
MY_RUBY_HOME=/home/ec2-user/.rvm/rubies/ruby-2.6.3
HISTFILESIZE=100000
NVM_DIR=/home/ec2-user/.nvm
USER=ec2-user
LS_COLORS=rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:
rvm_path=/home/ec2-user/.rvm
TMUX=/tmp/tmux-1000/cloud92.2,5342,1
rvm_prefix=/home/ec2-user
MAIL=/var/spool/mail/ec2-user
PATH=/home/ec2-user/.rvm/gems/ruby-2.6.3/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3@global/bin:/home/ec2-user/.rvm/rubies/ruby-2.6.3/bin:/home/ec2-user/.nvm/versions/node/v16.20.0/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3@global/bin:/home/ec2-user/.rvm/rubies/ruby-2.6.3/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3@global/bin:/home/ec2-user/.rvm/rubies/ruby-2.6.3/bin:/usr/local/bin:/usr/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/usr/local/bin:/home/ec2-user/.rvm/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/usr/local/bin:/home/ec2-user/.rvm/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/usr/local/bin:/home/ec2-user/.rvm/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin
C9_USER=Admin
HGUSER=Admin
PWD=/home/ec2-user/environment
EDITOR=
LANG=en_US.UTF-8
NODE_PATH=/home/ec2-user/.c9/node_modules
TMUX_PANE=%1
HISTCONTROL=ignoredups
rvm_version=1.29.8 (1.29.8)
HOME=/home/ec2-user
SHLVL=5
C9_PID=8052f845ae6f4bc8888d783afdde1b2f
C9_PROJECT=AWS-RGS-Workshop
LOGNAME=ec2-user
GEM_PATH=/home/ec2-user/.rvm/gems/ruby-2.6.3:/home/ec2-user/.rvm/gems/ruby-2.6.3@global
SSH_CONNECTION=35.172.155.194 6631 172.31.40.124 22
LESSOPEN=||/usr/bin/lesspipe.sh %s
NVM_BIN=/home/ec2-user/.nvm/versions/node/v16.20.0/bin
PROMPT_COMMAND=history -a;
PORT=8080
XDG_RUNTIME_DIR=/run/user/1000
IP=127.0.0.1
C9_HOSTNAME=184.72.153.49
RUBY_VERSION=ruby-2.6.3
_=/usr/bin/env
Admin:~/environment $ eksctl create cluster -f eksctl-cluster-actual.yml ; eksctl create iamidentitymapping --cluster $EKS_CLUSTER_NAME --region=$AWS_REGION --arn $rancherUser --group system:masters --username rancher
Error: metadata.name must be set
Error: --cluster=--region= and argument system:masters cannot be used at the same time
(reverse-i-search)`': ^C
Admin:~/environment $ vim eksctl-cluster-actual.yml 
Admin:~/environment $ env | grep AWS
C9_PROJECT=AWS-RGS-Workshop
Admin:~/environment $ ./env-setup.1.sh 
================ Set some ENV variables =================

An error occurred (AccessDenied) when calling the ListRoles operation: User: arn:aws:sts::019759562784:assumed-role/rancher-manager-stack-EKSCTLRole-D78Q8FNL2T9B/i-0d9daf0baeff2d308 is not authorized to perform: iam:ListRoles on resource: arn:aws:iam::019759562784:role/ because no identity-based policy allows the iam:ListRoles action

An error occurred (AccessDenied) when calling the ListRoles operation: User: arn:aws:sts::019759562784:assumed-role/rancher-manager-stack-EKSCTLRole-D78Q8FNL2T9B/i-0d9daf0baeff2d308 is not authorized to perform: iam:ListRoles on resource: arn:aws:iam::019759562784:role/ because no identity-based policy allows the iam:ListRoles action

An error occurred (AccessDenied) when calling the GetUser operation: User: arn:aws:sts::019759562784:assumed-role/rancher-manager-stack-EKSCTLRole-D78Q8FNL2T9B/i-0d9daf0baeff2d308 is not authorized to perform: iam:GetUser on resource: user rancher-cloud-credential-user because no identity-based policy allows the iam:GetUser action
Admin:~/environment $ env | grep AWS
C9_PROJECT=AWS-RGS-Workshop
Admin:~/environment $ env | grep EKS
Admin:~/environment $ 
marshkkm commented 1 year ago

@evdevr and I spoke to walk through the error, seems instructions were performed out of order mostly due to accommodating for missing instructions (for outside of Workshop env). Will update instructions as ref in #27