If you manually delete a resource that is being managed by terraform, it it not removed from the state file and becomes "orphaned".
You many see errors like this when running terraform:
1 error(s) occurred:
* aws_iam_role.s3_readonly (destroy): 1 error(s) occurred:
* aws_iam_role.s3_readonly (deposed #0): 1 error(s) occurred:
* aws_iam_role.s3_readonly (deposed #0): Error listing Profiles for IAM Role (s3_readonly) when trying to delete: NoSuchEntity: The role with name s3_readonly cannot be found.
This prevents terraform from running, even if you don't care about the missing resource such as when you're trying to delete everything, ie. running
Fortunately, terraform has a command for exactly this situation, to remove a resource from the state file:
terraform state rm <name of resource>
In the example above, the command would be
terraform state rm aws_iam_role.s3_readonly
Update 2017-08-25: Additional characters excluded due to problems with password handling in PHP applications using the Laravel framework on AWS ElasticBeanstalk
I needed to generate random master passwords for several Amazon RDS MySQL instances.
The specification is as follows:
The password for the master database user can be any printable ASCII character except "/", """, or "@". Master password constraints differ for each database engine.
MySQL, Amazon Aurora, and MariaDB
I came up with this:
head -n 1 < <(fold -w 41 < <(LC_ALL=C tr -d '@"$`!/'\'\\ < <(LC_ALL=C tr -dc '[:graph:]' < /dev/urandom)))
If you prefer to use pipes (rather than process substitution) the command would look like this:
cat /dev/urandom | LC_ALL=C tr -dc '[:graph:]' | tr -d '@"$`!/'\'\\ | fold -w 41 | head -n 1
take a stream of random bytes
remove all chars not in the set specified by [:graph:], ie. get rid of everything that is not a printable ASCII character
remove the chars that are explicitly not permitted by the RDS password specification and others that can cause problems if not handled correctly
split the stream into lines 41 characters long, ie. the maximum password length
stop after the first line