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

Boto3 conversion #32

Merged
merged 4 commits into from
Apr 4, 2020
Merged

Boto3 conversion #32

merged 4 commits into from
Apr 4, 2020

Conversation

pmkane
Copy link

@pmkane pmkane commented Feb 20, 2019

Hi there:

This a new PR to convert aws-ec2-assign-elastic-ip to use boto3, instead of boto.

Because boto3 still doesn't have get_instance_metadata() equivalent, it adds ec2-metadata as a requirement.

The only functional change in this PR is that AllowReassociation is always False, whereas in the current boto implementation, whether it is True or False depends on the date that your EC2 environment was created. See #24 for more details.

I've tested the use cases that broke in #28 or #29 and they both work correctly in this branch.

Patrick Michael Kane added 3 commits February 20, 2019 16:39
fix detecting associated addresses
fix two spelling errors
@pmkane
Copy link
Author

pmkane commented Mar 7, 2019

Just a quick bump on this -- if you'd prefer to stick with boto2, given the problems from the last release, I understand, but we will want to continue work in our fork to add features.

@przemyslaw-elias
Copy link

@sebdah It appears that we also ran into reassociation bug. Because the default has changed, it's impossible to send valid request with old boto. In order to fix this, a client change to boto3 is required.

Would you be willing to look into this?

@sebdah
Copy link
Owner

sebdah commented Apr 3, 2020

I'm really swamped with dealing with Covid-19 stuff at work, if someone could review the code and give this branch a go I'd be happy to merge, package and release.

Copy link

@przemyslaw-elias przemyslaw-elias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a python expert, but the code looks okay to me :)

Tested this branch on EC2 with the following:
pip install ec2_metadata git+https://github.com/pmkane/aws-ec2-assign-elastic-ip.git@boto3_conversion, worked well.

@pmkane Could you update to master?

@pmkane
Copy link
Author

pmkane commented Apr 3, 2020 via email

@pmkane
Copy link
Author

pmkane commented Apr 3, 2020

Done.

@sebdah
Copy link
Owner

sebdah commented Apr 4, 2020

Awesome, thanks guys. I'll get to this a little later today.

@sebdah sebdah changed the base branch from master to develop April 4, 2020 10:16
@sebdah sebdah merged commit 6275558 into sebdah:develop Apr 4, 2020
sebdah added a commit that referenced this pull request Apr 4, 2020
Features:

- Upgrade to boto3 [#32](#32)
@sebdah
Copy link
Owner

sebdah commented Apr 4, 2020

Thanks for the help here @pmkane and @przemyslaw-elias. I have released version 0.10.0 now.

@przemyslaw-elias
Copy link

przemyslaw-elias commented Apr 6, 2020

Guys, it looks like the merge to master didn't go as planned. Before that it's been working properly, but now it's giving an error:

Traceback (most recent call last):
  File "/usr/local/bin/aws-ec2-assign-elastic-ip", line 31, in <module>
    aws_ec2_assign_elastic_ip.main()
  File "/usr/local/lib/python2.7/site-packages/aws_ec2_assign_elastic_ip/__init__.py", line 59, in main
    address = _get_unassociated_address()
  File "/usr/local/lib/python2.7/site-packages/aws_ec2_assign_elastic_ip/__init__.py", line 115, in _get_unassociated_address
    all_addresses = connection.get_all_addresses()
  File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 566, in __getattr__
    self.__class__.__name__, item)

@pmkane in your PR you changed connection.get_all_addresses to connection.describe_addresses, but the same code has slipped through merge to master.

Moreover, I don't know whats wrong, but I had to manually run pip install ec2_metadata because it's been missing.

@sebdah
Copy link
Owner

sebdah commented Apr 6, 2020

Moreover, I don't know whats wrong, but I had to manually run pip install ec2_metadata because it's been missing.

Hmm, yes, there is a new dependency added. It must be added to the list of dependencies. Also it seems like the boto dependency should be bumped.

I'll prepare a bugfix PR shortly.

@sebdah sebdah mentioned this pull request Apr 6, 2020
@pmkane
Copy link
Author

pmkane commented Apr 6, 2020

Ugh, sorry -- I clearly rushed the merge. I am happy to submit a PR to clean up my own mess. Will do so, unless @sebdah has already gotten there.

@pmkane
Copy link
Author

pmkane commented Apr 6, 2020

Looks like you did, thank you @sebdah.

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

Successfully merging this pull request may close these issues.

None yet

3 participants