Skip to content

Commit

Permalink
And update readme (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
arianvp authored Jan 10, 2024
1 parent 6094ca9 commit c96adf7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
# NixOS AMIs

[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/arianvp/amis/badge)](https://securityscorecards.dev/viewer/?uri=github.com/arianvp/amis)

Temporary home for the soon to be official NixOS AMIs

## Costs and Sponorship
## Setting up account

Some steps need to be done manually to set up the account. This is a one time
process. These are hard to automate with Terraform.

First opt in to all regions:

```bash
nix run .#enable-regions
```

Then request a quota increase for the number of AMIs you want to publish.
This will create support tickets in all regions. You can check the status
of the tickets in the AWS console. It might take a few days for the tickets
to be resolved.

```bash
nix run .#request-public-ami-quota-increase -- --desired-value 1000
```

Testing all this and storing all the AMIs whilst I figure out moving this to the
NixOS Foundation costs me non-significant amount of money. If you think this
cause is worthwhile please consider sponsoring me through Github Sponsors.
Finally enable public AMIs:

Each image is `4GB` in size at the moment. EBS Snapshots cost `$0.05` per GB
per month. So each image costs `$0.20` per month to store. We replicate across
all 32 AWS regions so that's `$6.40` per month per image.
```bash
nix run .#disable-image-block-public-access
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def get_public_ami_service_quota(servicequotas):


def main():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--desired-value", type=int, default=100)
args = parser.parse_args()
logging.basicConfig(level=logging.INFO)
ec2 = boto3.client("ec2")
regions = ec2.describe_regions()["Regions"]
Expand All @@ -18,14 +22,13 @@ def main():
"service-quotas", region_name=region["RegionName"])
service_quota = get_public_ami_service_quota(servicequotas)
try:
desired_value = 100
if service_quota['Value'] >= desired_value:
if service_quota['Value'] >= args.desired_value:
logging.info(
f"Quota for {region['RegionName']} is already {service_quota['Value']}")
continue
logging.info(
f"Requesting quota increase for {region['RegionName']}")
servicequotas.request_service_quota_increase( ServiceCode="ec2", QuotaCode=service_quota['QuotaCode'], DesiredValue=100,)
servicequotas.request_service_quota_increase( ServiceCode="ec2", QuotaCode=service_quota['QuotaCode'], DesiredValue=args.desired_value)
except Exception as e:
logging.warn(e)

Expand Down

0 comments on commit c96adf7

Please sign in to comment.