File:  [NetBSD Developer Wiki] / wikisrc / amazon_ec2 / bsdec2_image_upload.mdwn
Revision 1.1: download - view: text, annotated - select for diffs
Wed Oct 14 22:18:01 2020 UTC (6 weeks, 6 days ago) by wiki
Branches: MAIN
CVS tags: HEAD
commit uncommitted entries

    1: # Creating a NetBSD AMI with bsdec2-image-upload
    2: 
    3: ## About bsdec2-image-upload
    4: 
    5: The [bsdec2-image-upload](https://github.com/cperciva/bsdec2-image-upload) tool automates creation of AMIs based on raw disk images. This tool is available in pkgsrc as [sysutils/bsdec2-image-upload](https://pkgsrc.se/sysutils/bsdec2-image-upload).
    6: 
    7: ## Getting a disk image
    8: 
    9: The following images are configured to automatically detect an EC2 environment and resize the root disk at boot. Creating a custom image is not covered in this document.
   10: 
   11: ### x86
   12: 
   13: * NetBSD -current: <http://nycdn.netbsd.org/pub/NetBSD-daily/HEAD/latest/images/NetBSD-9.99.72-amd64-live.img.gz>
   14: * NetBSD 9.x: *not supported*
   15: 
   16: ### Arm
   17: 
   18: * NetBSD -current: <http://nycdn.netbsd.org/pub/NetBSD-daily/HEAD/latest/evbarm-aarch64/binary/gzimg/arm64.img.gz>
   19: * NetBSD 9.x: <http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-9/latest/evbarm-aarch64/binary/gzimg/arm64.img.gz>
   20: 
   21: ## Prerequisites
   22: 
   23: ### Install bsdec2-image-upload
   24: 
   25: Install sysutils/bsdec2-image-upload from pkgsrc.
   26: 
   27: ### Setup AWS credentials
   28: 
   29: In the [IAM Management Console](https://console.aws.amazon.com/iam), create an access key. Enter these into in a file named *keyfile.txt*:
   30: 
   31: [[!template  id=filecontent name="keyfile.txt" text="""
   32: ACCESS_KEY_ID=your_access_key_id
   33: ACCESS_KEY_SECRET=your_access_key_secret
   34: """]]
   35: 
   36: ### Create S3 bucket for image upload
   37: 
   38: An S3 bucket is required for temporary storage during the upload and conversion process. This can be created on the [S3 Management Console](https://s3.console.aws.amazon.com).
   39: 
   40: ## Creating an AMI
   41: 
   42: [[!template  id=filecontent name="x86" text="""
   43: $ gunzip NetBSD-9.99.72-amd64-live.img.gz
   44: $ AWS_REGION=us-east-1
   45: $ S3BUCKET=my-bucket-name
   46: $ bsdec2-image-upload --sriov --ena NetBSD-9.99.72-amd64-live.img "NetBSD 9.99.72 x86 2020-09-10" "NetBSD/amd64 -current (9.99.72) built on Sep 10 2020" ${AWS_REGION} ${S3BUCKET} keyfile.txt
   47: """]]
   48: 
   49: [[!template  id=filecontent name="Arm" text="""
   50: $ gunzip arm64.img.gz
   51: $ AWS_REGION=us-east-1
   52: $ S3BUCKET=my-bucket-name
   53: $ bsdec2-image-upload --sriov --ena --arm64 arm64.img "NetBSD 9.99.72 Arm 2020-09-10" "NetBSD/evbarm -current (9.99.72) built on Sep 10 2020" ${AWS_REGION} ${S3BUCKET} keyfile.txt
   54: """]]
   55: 
   56: ### Cleanup
   57: 
   58: Once the images are uploaded, some artifacts will be left in the S3 bucket. These can be safely deleted.
   59: 
   60: ## Starting an instance
   61: 
   62: On the [EC2 Management Console](https://console.aws.amazon.com/ec2), select the region matching the AMI you just uploaded. Then under the AMIs section on the left, select your newly created AMI and click the Launch button to create a new instance.
   63: 
   64: The credentials specified during creation of the instance can be used to login with ssh as the root user after NetBSD has booted:
   65: 
   66: [[!template  id=filecontent name="remote login" text="""
   67: $ ssh -i netbsd.pem root@my-instance-ip
   68: """]]

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb