Sets USE_MSI env var, get latest version of terraform, reflect changes in readme.

This commit is contained in:
Jeffrey Cline
2018-02-27 14:19:21 -08:00
parent 6b3815b7ce
commit 94e04a1d87
4 changed files with 25 additions and 15 deletions

View File

@ -89,6 +89,7 @@ TEMPLATEFOLDER="/home/$USERNAME/tfTemplate"
REMOTESTATEFILE="$TEMPLATEFOLDER/remoteState.tf"
TFENVFILE="/home/$USERNAME/tfEnv.sh"
CREDSFILE="$TEMPLATEFOLDER/azureProviderAndCreds.tf"
PROFILEFILE="/home/$USERNAME/.profile"
mkdir $TEMPLATEFOLDER
@ -111,6 +112,14 @@ chown -R $USERNAME:$USERNAME /home/$USERNAME/tfTemplate
touch $TFENVFILE
echo "export ARM_SUBSCRIPTION_ID=\"$SUBSCRIPTION_ID\"" >> $TFENVFILE
echo "export ARM_CLIENT_ID=\"$MSI_PRINCIPAL_ID\"" >> $TFENVFILE
echo "export USE_MSI=true" >> $TFENVFILE
# Set these variables in the profile
echo "echo export ARM_SUBSCRIPTION_ID=\"$SUBSCRIPTION_ID\" >>$PROFILEFILE" >> $TFENVFILE
echo "echo export ARM_CLIENT_ID=\"$MSI_PRINCIPAL_ID\" >>$PROFILEFILE" >> $TFENVFILE
echo "echo export USE_MSI=true >>$PROFILEFILE" >> $TFENVFILE
# Add contributor permissions to the MSI for entire subscription
echo "az login" >> $TFENVFILE
echo "az role assignment create --assignee \"$MSI_PRINCIPAL_ID\" --role 'b24988ac-6180-42a0-ab88-20f7382dd24c' --scope /subscriptions/\"$SUBSCRIPTION_ID\"" >> $TFENVFILE
chmod 755 $TFENVFILE
@ -121,9 +130,3 @@ logger -t devvm "Creating the container for remote state"
az login --msi
az storage container create -n terraform-state --account-name $STORAGE_ACCOUNT_NAME --account-key $STORAGE_ACCOUNT_KEY
logger -t devvm "Container for remote state created: $?"
if [[ -v DESKTOPINSTALL ]]; then
echo "Installing Mate Desktop"
bash ./desktop.sh
echo "Desktop installed"
fi