Skip to content

Boto3 conversion - #32

Merged
sebdah merged 4 commits into
sebdah:developfrom
pmkane:boto3_conversion
Apr 4, 2020
Merged

sebdah merged 4 commits into
sebdah:developfrom
pmkane:boto3_conversion

Conversation

@pmkane

@pmkane pmkane commented Feb 20, 2019

Copy link
Copy Markdown

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

pmkane commented Mar 7, 2019

Copy link
Copy Markdown
Author

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

@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

sebdah commented Apr 3, 2020

Copy link
Copy Markdown
Owner

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.

@przemyslaw-elias przemyslaw-elias left a comment

Copy link
Copy Markdown

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

pmkane commented Apr 3, 2020 via email

Copy link
Copy Markdown
Author

@pmkane

pmkane commented Apr 3, 2020

Copy link
Copy Markdown
Author

Done.

@sebdah

sebdah commented Apr 4, 2020

Copy link
Copy Markdown
Owner

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

sebdah commented Apr 4, 2020

Copy link
Copy Markdown
Owner

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

@przemyslaw-elias

przemyslaw-elias commented Apr 6, 2020 •

Copy link
Copy Markdown

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

sebdah commented Apr 6, 2020

Copy link
Copy Markdown
Owner

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

pmkane commented Apr 6, 2020

Copy link
Copy Markdown
Author

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

pmkane commented Apr 6, 2020

Copy link
Copy Markdown
Author

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.

3 participants