Closed Name404Error closed 8 months ago
Hi! Do you have AWS credentials you are using that are stored in your environment? Let me try this as well and make sure something didn't recently break.
I do not, I saw the "Running locally" section in the readme and wasn't sure where I need to put that info.
Got it! There are 2 options to do this, one with docker and one on your machine. I personally use Docker but have plans to improve the devex for building natively as well.
Docker
docker build --build-arg AWS_ACCESS_KEY_ID=YOURKEY --build-arg AWS_SECRET_ACCESS_KEY=YOURKEY -t ec2instances.info .
Native
export AWS_ACCESS_KEY=YOURKEY
export AWS_SECRET_ACCESS_KEY=YOURKEY
P.S. One tip on running docker to develop locally. First run it (notice the http envvar and the volume)
docker run -it --rm --name ec2instances -v $(pwd):/opt/app --env HTTP_HOST=0.0.0.0 -p 8080:8080 ec2instances.info
Then jump into it:
docker exec -it ec2instances /bin/bash
Thank you for the help. Now, when running invoke build, I get
botocore.exceptions.NoCredentialsError: Unable to locate credentials None
Then the code just stops, were the 2 access key from before not the credentials?
I'm also running on windows if that changes things
Ok that means the credentials are not being saved or loaded - please see here for information on how to set this for every environment, https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
when I do echo %AWS_ACCESS_KEY% or set AWS_ACCESS_KEY I see my key in the env, doesn't that mean it is saved/loadable?
my whole procedure atm is cd ec2instances.info/ python -m venv env env\Scripts\activate pip install -r requirements.txt set AWS_ACCESS_KEY=my key set AWS_SECRET_ACCESS_KEY=the other key invoke build Then it gives "botocore.exceptions.NoCredentialsError: Unable to locate credentials"
Got it. I actually have a windows VM sitting around so let me spin that up and get back to you here.
Same problem on Mac, tried both build-arg and env variable
@Name404Error @Elentary the two envvars you need are this:
export AWS_ACCESS_KEY_ID=<your key>
export AWS_SECRET_ACCESS_KEY=<your key>
These can also be set in the ~/.aws/credentials
file like so:
[default]
aws_access_key_id = <your key>
aws_secret_access_key = <your key>
Similarly, these can be passed to a docker environment like this:
docker build --no-cache --build-arg AWS_ACCESS_KEY_ID=<your key> --build-arg AWS_SECRET_ACCESS_KEY=<your key> -t ec2instances.info .
If none of these options are working for you, you can always download the instances.json file for any of the services directly from the website:
curl https://instances.vantage.sh/instances.json -o instances.json
I'm experiencing the same issue trying to spin up locally on Mac.
Here are my steps so far:
docker build --build-arg AWS_ACCESS_KEY_ID=<key id> --build-arg AWS_SECRET_ACCESS_KEY=<key> -t ec2instances.info .
FileNotFoundError: [Errno 2] No such file or directory: 'www/cache/instances.json'
. I've even tried downloading instances.json and placing it into 'ec2instances.info/www/cache/' and I still get the error.Could this be something to do with the permissions of the AWS User? I've created a new IAM user whose credentials I'm using with the following permissions:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:DescribeInstanceTypes", "ec2:DescribeRegions", "pricing:*" ], "Resource": "*" } ] }
Perhaps there's a permissions set or other AWS setup that I'm missing?
That's almost certainly what's happening. In the log output you should see an Access Denied error but here is the boto3 call that cache.py
uses https://github.com/vantage-sh/ec2instances.info/blob/master/cache.py#L337
@EverettBerry Is there an example of a permission set for the IAM user that will allow spinning up localdev? The project README.md says all you need to run locally are the permissions I listed above, but that doesn't seem to actually cover what's required.
Alternatively maybe I can remove elasticache from my local instance since I don't need that currently for my use case.
I believe the permission would be: elasticache:DescribeEngineDefaultParameters
. It would be great if you could check that actually. I can update the README accordingly.
I also created this pull request a while back which should make it even easier to run locally using docker-compose, which is shipped as part of the Docker application on macOS.
@cristim sorry for the delay here. I'm planning to merge these changes this month.
Believe this was resolved in #713
I was trying to run the code locally and when I typed Invoke build it gave a error saying no instance.json. I was wondering what this file is and how do I get/generate it.