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

[WIP]New modules to list AWS API Gateway. #55859

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
3 participants
@cahlchang
Copy link
Contributor

commented Apr 28, 2019

SUMMARY

Added list module for AWS API Gateway.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

aws_api_gateway_facts

ANSIBLE VERSION
(myenv) $ ansible --version
ansible 2.9.0.dev0 config file = None configured module search path =
['/Users/myuser/.ansible/plugins/modules',
'/usr/share/ansible/plugins/modules'] ansible python module location =
/Users/myuser/git/ansible/lib/ansible executable location = ./bin/ansible
python version = 3.7.3 (default, Mar 27 2019, 09:23:15) [Clang 10.0.1
(clang-1001.0.46.3)]
ADDITIONAL INFORMATION

- hosts: localhost
  tasks:
    - aws_api_gateway_facts:
        profile: default
        api_id: 'myapigatewayid'
      register: facts1

    - aws_api_gateway_facts:
        profile: default
      register: facts2

    - debug:
        msg: "{{ facts1 }}"

    - debug:
        msg: "{{ facts2 }}"
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Apr 28, 2019

@cahlchang, just so you are aware we have a dedicated Working Group for aws.
You can find other people interested in this in #ansible-aws on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Apr 28, 2019

@BobBoldin @Constantin007 @Constantin07 @Deepakkothandan @Etherdaemon @Java1Guy @Madhura-CSI @MichaelBaydoun @Sodki @Zeekin @adq @akazakov @alachaum @amir343 @anryko @bekelchik @brandond @captainkerk @chenl87 @defunctio @dennisconrad @dkhenry @fiunchinho @fivethreeo @flowerysong @garethr @gobins @gunzy83 @gurumaia @hsingh @hyperized @iiibrad @infectsoldier @j-carl @jarv @jimbydamonk @jmenga @joelthompson @jonhadfield @jonmer85 @joshsouza @jsdalton @jsmartin @kaczynskid @leedm777 @linuxdynasty @loia @lwade @michaeljs1990 @minichate @mjschultz @mmochan @nand0p @naslanidis @nathanwebsterdotme @nerzhul @nickball @orthanc @ozbillwang @piontas @pjodouin @prasadkatti @psykotox @ptux @pwnall @raags @rafaeldriutti @rickmendes @roadmapper @rrey @ruimoreira @ryansydnor @scicoin-project @scottanderson42 @sdubrul @shepdelacreme @silviud @slapula @steynovich @tastychutney @tgerla @timmahoney @tomislacker @tsiganenok @viper233 @whiter @willricardo @wilvk @wimnat @yaakov-github @zacblazic @zbal @zimbatm

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

try:
import boto3
from botocore.exceptions import ClientError, BotoCoreError
HAS_BOTO3 = True

This comment has been minimized.

Copy link
@willthames

willthames Apr 29, 2019

Contributor

HAS_BOTO3 is not needed with AnsibleAWSModule

except ImportError:
HAS_BOTO3 = False
from ansible.module_utils.aws.core import AnsibleAWSModule
from ansible.module_utils.ec2 import (boto3_conn, ec2_argument_spec, get_aws_connection_info, camel_dict_to_snake_dict)

This comment has been minimized.

Copy link
@willthames

willthames Apr 29, 2019

Contributor

boto3_conn, ec2_argument_spec, get_aws_connection_info
are not needed with AnsibleAWSModule

else:
api_result = client.get_rest_apis()
except (ClientError, BotoCoreError) as err:
module.fail_json(msg=err.message, exception=traceback.format_exc(), **camel_dict_to_snake_dict(err.response))

This comment has been minimized.

Copy link
@willthames

willthames Apr 29, 2019

Contributor

use module.fail_json_aws(msg=err.message)


region, ec2_url, aws_connect_params = get_aws_connection_info(module, boto3=True)

if region:

This comment has been minimized.

Copy link
@willthames

willthames Apr 29, 2019

Contributor

just use client = module.client('apigateway')

del result['ResponseMetadata']
api_result = {'items': [result]}
else:
api_result = client.get_rest_apis()

This comment has been minimized.

Copy link
@willthames

willthames Apr 29, 2019

Contributor

You'll need to handle pagination if there are a lot of APIs. Should probably handle rate limiting here too

https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/GUIDELINES.md#api-throttling-rate-limiting-and-pagination

description: a list of api-gateway
returned: always
type: complex
contains:

This comment has been minimized.

Copy link
@willthames

willthames Apr 29, 2019

Contributor

This does not seem to be at all comprehensive compared to what is in https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/apigateway.html#APIGateway.Client.get_rest_apis

You can generate the RETURN list using hacking/return_skeleton_generator.py

@ansibot ansibot added the stale_ci label May 7, 2019

@cahlchang cahlchang changed the title New modules to list AWS API Gateway. [WIP]New modules to list AWS API Gateway. May 8, 2019

@cahlchang

This comment has been minimized.

Copy link
Contributor Author

commented May 8, 2019

Thank you for the review.
I will fix the contents and submit it in the near future.

@ansibot ansibot added the WIP label May 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.