You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Adde check for IMDS version
* move metadata below endpoint declaration
Moved check for IMDS version to below the metadata_endpoint declaration to be able to take advantage of it.
* updated default to IMDSv2
updated the comments to reflect IMDSv2 as the default.
* Add IMDS version 2 to README.md
Changing IMDSv2 to be default. Updating the README to reflect this change.
* dealing with IMDS being blocked
Taking in to account if a firewall is configured to block IMDS calls. And setting default to version 2.
* check IMDSv2 Token endpoint
Checks the IMDSv2 Token endpoint to verify if IMDSv2 is active and available.
If not, checks to verify if IMDSv1 endpoint is active and available.
* wrap curl in variable
curl command failure cause script to abort. Wrapping inside a variable should allow the script to continue.
* adding sudo to curl
curl to IMDS endpoint fails as a normal user in some cases (including testing with docker-compose).
* identify version failure in output
Identify in the output if it was IMDSv1 or IMDSv2 that failed.
* remove version lock from Dockerfile
cnf-lint and pyrsistent unlocking version
* unlock cnf-lint and pyrsistent versions
Unlocking versions for cnf-lint and pyrsistent in Docker file for Ubuntu 20.04
* adding check for user override to IMDS version
Adding if statement to check if the IMDS version has been requested.
`bash-commons` supports both Instance Metadata Service (IMDS) version 1 and 2. Gruntwork and AWS both recommend using version 2 of the Instance Metadata Service whenever possible. Although version 1 is still supported and considered fully secure by AWS, version 2 has been specially hardened against specific threat vectors and is therefore preferable.
76
+
`bash-commons` supports both Instance Metadata Service (IMDS) version 1 and 2. Gruntwork and AWS both recommend using version 2 of the Instance Metadata Service whenever possible. Although version 1 is still supported and considered fully secure by AWS, version 2 has been specially hardened against specific threat vectors and is therefore preferable. Version 2 is now the default since all new instances support it by default.
77
77
78
78
To understand more about Instance Metadata Service version 2 and its features, read [the official AWS documentation on IMDSv2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html).
79
79
80
+
If you need help detecting what is still using IMDSv1 AWS has a PacketAnalyzer:
81
+
https://github.com/aws/aws-imds-packet-analyzer
82
+
80
83
There are two ways to specify the version of the Instance Metadata Service that `bash-commons` should use:
81
84
82
85
1. Set the environment variable `GRUNTWORK_BASH_COMMONS_IMDS_VERSION` to the version of IMDS that you wish to use. Valid values are either `1` or `2`.
@@ -132,7 +135,7 @@ Here's an overview of the modules available in `bash-commons`:
132
135
Instance Metadata](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html). These thin
133
136
wrappers give you a shorthand way to fetch certain information (e.g., information about an EC2 Instance, such as its
134
137
private IP, public IP, Instance ID, and region). Moreover, you can swap out `aws.sh` with a version that returns mock
135
-
data to make it easy to run your code locally (e.g., in Docker) and to run unit tests.
138
+
data to make it easy to run your code locally (e.g., in Docker) and to run unit tests. This requires IMDS to be enabled.
136
139
137
140
* `aws-wrapper.sh`: A collection of "high level" wrappers for the [AWS CLI](https://aws.amazon.com/cli/) and [EC2
138
141
Instance Metadata](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) to simplify common
# A convenience variable representing 3 hours, for use in requesting a token from the IMDSv2 endpoint
16
18
readonly three_hours_in_s=10800
17
19
# A convenience variable representing 6 hours, which is the maximum configurable session duration when requesting
18
20
# a token from IMDSv2
19
21
readonly six_hours_in_s=21600
20
-
# By default, we use Instance Metadata service version 1. Although version 2 is preferred, version 1 is "fully secure" according to Amazon. We'll continue defaulting to version 1 as long as we're updating our dependent modules to take advantage of this new functionality in bash-commons. Once we've completed our migration, we will begin defaulting to version 2. Users can always specify the version of the Instance Metadata Service they want bash-commons to consult by setting the environment variable GRUNTWORK_BASH_COMMONS_IMDS_VERSION
21
-
default_instance_metadata_version="1"
22
+
23
+
# Detect if the instance is using IMDSv2 or if it is using IMDSv1 still.
24
+
# Users can always specify the version of the Instance Metadata Service they want bash-commons
25
+
# to consult by setting the environment variable GRUNTWORK_BASH_COMMONS_IMDS_VERSION
26
+
# Defaults to IMDSv2 since that is now enabled by default on instances (IMDS only has two options,
27
+
# "optional" = both v1 and v2, or "required" = v2 only). All new instances support v2 now.
28
+
if [[ -z"$GRUNTWORK_BASH_COMMONS_IMDS_VERSION" ]];then
0 commit comments