vantage-sh / ec2instances.info

Amazon EC2 instance comparison site
https://ec2instances.info
MIT License
5.13k stars 579 forks source link

instance.json #642

Closed Name404Error closed 8 months ago

Name404Error commented 2 years ago

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.

EverettBerry commented 2 years 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.

Name404Error commented 2 years ago

I do not, I saw the "Running locally" section in the readme and wasn't sure where I need to put that info.

EverettBerry commented 2 years ago

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.

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
Name404Error commented 2 years ago

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?

Name404Error commented 2 years ago

I'm also running on windows if that changes things

EverettBerry commented 2 years ago

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

Name404Error commented 2 years ago

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"

EverettBerry commented 2 years ago

Got it. I actually have a windows VM sitting around so let me spin that up and get back to you here.

Elentary commented 1 year ago

Same problem on Mac, tried both build-arg and env variable

EverettBerry commented 1 year ago

@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
aprice-dev commented 1 year ago

I'm experiencing the same issue trying to spin up locally on Mac.

Here are my steps so far:

  1. Clone the repo
  2. cd into repo
  3. run docker build --build-arg AWS_ACCESS_KEY_ID=<key id> --build-arg AWS_SECRET_ACCESS_KEY=<key> -t ec2instances.info .
  4. Fail with exception 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?

EverettBerry commented 1 year ago

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

aprice-dev commented 1 year ago

@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.

EverettBerry commented 1 year ago

I believe the permission would be: elasticache:DescribeEngineDefaultParameters. It would be great if you could check that actually. I can update the README accordingly.

cristim commented 1 year ago

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.

https://github.com/vantage-sh/ec2instances.info/pull/685

EverettBerry commented 1 year ago

@cristim sorry for the delay here. I'm planning to merge these changes this month.

EverettBerry commented 8 months ago

Believe this was resolved in #713