Bash – set variable with or without export are different

I am working on an AWS ec2 instance provisioning script today. I am using Packer to provision the instance and build an AMI. The instance is running Ubuntu. There is a very annoying error when I am using ‘apt-get -y upgrade’ or ‘apt-get -y install’:

debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin:

Google it and not hard to find the fix is to add “DEBIAN_FRONTEND=noninteractive” in your script
(credit to link to stackoverflow)

However, it still doesn’t work for me until I realize I need to put in ‘export’:

export DEBIAN_FRONTEND=noninteractive

Apparently ‘export’ will make the variable is available to any process you run from your current shell process (not parent process though). Without ‘export’, the variable scope is restricted to the shell, and is not available to any other process.
(credit to link to stackoverflow)

When you need more disk space for AWS WorkDoc on AWS WorkSpace

As of today, AWS WorkSpace (Standard) only comes with 50G user data (D drive). You can install WorkDoc client on your WorkSpace to have your data synced. However, if your WorkDoc data exceed 50G, this will fill up your WorkSpace D drive very quickly.

Here a work around:

  • Start a EC2 Windows instance with a big enough EBS, say 300G. This instance must be launched in the same VPC as your WorkSpace.
  • Join this instance to your AWS Directory, same Directory as your WorkSpace
  • Install WorkDoc client on this EC2 instance and share the WorkDoc folder to Directory/Users
  • Added this instance to the existing WorkSpace Controller security group or make sure it is accessible to WorkSpaces via Port 445
  • In each WorkSpace, just map the shared drive on this EC2 instance. \\[ec2 instance computer name]\workdoc

There you have it, good speed, plenty of spaces for your WorkDoc data.

For how to join EC2 instance to your AWS Directory, please refer to this Doc (I am in AWS Sydney region, and we can only do this manually):

You will also be able to add Directory Management tools on this EC2 instance for management purpose.

Hope this helps. If you have other ideas and suggestions, please feel free to let me know.