Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instance.json #642

Closed
Name404Error opened this issue Jul 14, 2022 · 17 comments
Closed

instance.json #642

Name404Error opened this issue Jul 14, 2022 · 17 comments

Comments

@Name404Error
Copy link

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
Copy link
Contributor

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
Copy link
Author

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

@EverettBerry
Copy link
Contributor

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

@Name404Error
Copy link
Author

Name404Error commented Jul 14, 2022

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
Copy link
Author

I'm also running on windows if that changes things

@EverettBerry
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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

@Elentary
Copy link

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

@EverettBerry
Copy link
Contributor

@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
Copy link

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
Copy link
Contributor

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
Copy link

@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
Copy link
Contributor

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
Copy link
Contributor

cristim commented May 11, 2023

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.

#685

@EverettBerry
Copy link
Contributor

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

@EverettBerry
Copy link
Contributor

Believe this was resolved in #713

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants