mock-instance-profile
provides a way to run ec2 instance profile on local linux or mac to simulate running on an ec2 instance. This provides a native capability to work with AWS SDKs
Read the blog post for a detailed walkthrough: aws instance profile for local development
Follow the installation guide for amazon-ec2-metadata-mock to install ec2-metadata-mock before using mock-instance-profile.
ensure you have python3 installed then install the python dependencies with pip3.
$ pip3 install -r requirements.txt
To mock metadata you must have some credentials on your system that boto3 can read via the default credential chain.
run mock-instance-profile
with the IAM role that you would like to assume credentials for.
$ ./mock-instance-profile arn:aws:iam::55555555555:role/my-test-role
Password:
Using configuration from file: /Users/test-user/.aws/mock_config.json
2022/07/15 07:42:16 Initiating ec2-metadata-mock for all mocks on port 80
Flags:
config-file: /Users/test-user/.aws/mock_config.json
hostname: 169.254.169.254
port: 80