{"id":16151287,"url":"https://github.com/stefansundin/bottlerocket-bootstrap-associate-eip","last_synced_at":"2025-04-28T12:56:00.859Z","repository":{"id":148602487,"uuid":"535543763","full_name":"stefansundin/bottlerocket-bootstrap-associate-eip","owner":"stefansundin","description":"A bootstrap container for Bottlerocket that associates an elastic IP address to the EC2 instance when it starts up.","archived":false,"fork":false,"pushed_at":"2025-03-20T00:36:21.000Z","size":158,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T09:41:29.347Z","etag":null,"topics":["bottlerocket"],"latest_commit_sha":null,"homepage":"https://gallery.ecr.aws/stefansundin/bottlerocket-bootstrap-associate-eip","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stefansundin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-12T06:48:29.000Z","updated_at":"2025-03-20T00:36:00.000Z","dependencies_parsed_at":"2024-01-30T23:51:50.182Z","dependency_job_id":"131eee05-a01e-45bb-aaaa-d9616cd6f97a","html_url":"https://github.com/stefansundin/bottlerocket-bootstrap-associate-eip","commit_stats":{"total_commits":39,"total_committers":1,"mean_commits":39.0,"dds":0.0,"last_synced_commit":"b0b5fc7f716b35662e6ee15434ab5aaf59efc1fd"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefansundin%2Fbottlerocket-bootstrap-associate-eip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefansundin%2Fbottlerocket-bootstrap-associate-eip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefansundin%2Fbottlerocket-bootstrap-associate-eip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefansundin%2Fbottlerocket-bootstrap-associate-eip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefansundin","download_url":"https://codeload.github.com/stefansundin/bottlerocket-bootstrap-associate-eip/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246453568,"owners_count":20779978,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bottlerocket"],"created_at":"2024-10-10T00:55:37.634Z","updated_at":"2025-03-31T10:31:25.386Z","avatar_url":"https://github.com/stefansundin.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is a bootstrap container for Bottlerocket that associates an elastic IP address to the EC2 instance when it starts up. This is useful if you want to run an EC2 instance that maintains the same IP address even if it is replaced. You can also associate an address from a pool of elastic IP addresses (see below for additional options).\n\nBecause Bottlerocket doesn't allow for traditional startup scripts in the user data, you can't just run aws-cli commands like you may be used to. Bottlerocket provides a way to run bootstrap containers instead, which you can use to configure the system when it starts up.\n\nA Rust program compiled using musl was picked to minimize the size of the docker image (the docker image is about 4 MB compressed). It is published on Amazon Public ECR: https://gallery.ecr.aws/stefansundin/bottlerocket-bootstrap-associate-eip\n\nHere's how to configure it in your Bottlerocket user data:\n\n```toml\n[settings.bootstrap-containers.associate-eip]\nsource = \"public.ecr.aws/stefansundin/bottlerocket-bootstrap-associate-eip:latest\"\nmode = \"once\"\nessential = false\nuser-data = \"ZWlwYWxsb2MtMDEyMzQ1Njc4OTBhYmNkZWYK\"\n```\n\nThe `user-data` contains the Elastic IP Allocation ID that you want to associate with the instance, encoded using base64. You can generate it like this:\n\n```shell\necho eipalloc-01234567890abcdef | base64\n```\n\n### Additional options\n\nThere are additional features besides the simple use-case demonstrated above. To use the additional options you need to pass in a JSON string in the `user-data` instead of just the `eipalloc` identifier.\n\n```shell\necho '{\"AllocationId\":\"eipalloc-01234567890abcdef\",\"AllowReassociation\":true}' | base64\n```\n\nIf you want to dynamically find an EIP to use, e.g. based on tags, then you can use the `Filters` option (equivalent to [`--filters`](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-addresses.html#options) for `aws ec2 describe-addresses`):\n\n```shell\necho '{\"Filters\":[{\"Name\":\"tag:Pool\",\"Values\":[\"ecs\"]}]}' | base64\n```\n\n\u003e [!WARNING]\n\u003e When `Filters` is used, the program will try to pick an unallocated EIP at random. If all the EIPs are in use then one will be chosen at random anyway. Set `AllowReassociation` to `false` to exit with an error instead.\n\nYou can specify an empty array to have the program pick any EIP in the account:\n\n```shell\necho '{\"Filters\":[]}' | base64\n```\n\nReference:\n\n- Either `AllocationId` or `Filters` is required.\n- `AllowReassociation` is `true` if omitted.\n\n\n## Supported Bottlerocket versions\n\nTested on Bottlerocket v1.9.2, v1.10.0, v1.26.2, and v1.34.0.\n\n\n## IAM Permissions\n\nMake sure your instance has permissions to associate elastic IP addresses.\n\n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"ec2:AssociateAddress\",\n                \"ec2:DescribeAddresses\"\n            ],\n            \"Resource\": \"*\"\n        }\n    ]\n}\n```\n\nYou only need `ec2:DescribeAddresses` if you want to use the `Filters` option.\n\n\n## Troubleshooting\n\nYou can get the output from the docker container by running:\n\n```shell\nenter-admin-container\nsudo sheltie\njournalctl -u bootstrap-containers@associate-eip.service\n```\n\nIf you are unable to connect to the instance then wait 10 minutes and then check the EC2 instance system log.\n\nIf you want more logging enabled then use the `debug` image:\n\n```toml\nsource = \"public.ecr.aws/stefansundin/bottlerocket-bootstrap-associate-eip:debug\"\n```\n\n\n## Developing\n\nThere is an integration test that simulates the required environment.\n\n```\nexport RUST_LOG=aws\ncargo test -- --nocapture --test-threads=1\n```\n\n\n## Feedback\n\nIf you have ideas for improvements, please open an issue or a pull request.\n\nIf you have questions then please open an issue or a discussion.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefansundin%2Fbottlerocket-bootstrap-associate-eip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefansundin%2Fbottlerocket-bootstrap-associate-eip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefansundin%2Fbottlerocket-bootstrap-associate-eip/lists"}