Here’s an example of a bash script that enables a specific AWS Directory for use with Amazon Workspaces using the AWS CLI:
#!/bin/bash # Set the AWS CLI region aws configure set default.region us-west-2 # Specify the directory ID and the directory name directory_id="d-1234567890" directory_name="example-directory" # Enable the directory for use with Amazon Workspaces aws workspaces enable-workspace-directory --directory-id $directory_id # Confirm that the directory has been enabled enabled_directories=$(aws workspaces describe-workspace-directories --directory-ids $directory_id --query 'Directories.DirectoryId' --output text) if [ $enabled_directories == $directory_id ]; then echo "Success: $directory_name has been enabled for use with Amazon Workspaces." else echo "Error: $directory_name could not be enabled for use with Amazon Workspaces." fi
In this example, replace
d-1234567890 with the actual ID of the directory you want to enable for use with Amazon Workspaces. This bash script uses the AWS CLI to enable the specified directory for use with Amazon Workspaces, and then confirms that the directory has been successfully enabled by checking the list of enabled directories. If the directory has been successfully enabled, the script will print a success message, and if not, it will print an error message.