mercredi 8 janvier 2020

How do you mock a rest api in moto with attached policies?

I'm trying to create a mocked rest api with an attached policy, but when the API is created it doesn't seem like moto's returning that policy.

@mock_apigateway
def test_returns_with_permissive_policy_policy(self):
    policy_document = """{
        'Version': '2012-10-08',
        'Statement': {
            'Effect': 'Allow',
            'Principal': '*',
            'Action': ['rds:*'],
            'Resource': '*',
            'Condition': {'IpAddress': {'AWS:SourceIP': ['0.0.0.0/0']}},
        },
    }"""
    rest_api_dict = dict(name='foo',
                         description='bar',
                         version='1.0.1',
                         cloneFrom='foo',
                         minimumCompressionSize=123,
                         apiKeySource='HEADER',
                         endpointConfiguration={
                             'types': [
                                 'REGIONAL',
                             ],
                         },
                         policy=policy_document,
                         )
    api = self.client.create_rest_api(**rest_api_dict)
    print(api)

What am I doing wrong? Similarly other fields like endpointConfiguration is not returned either.

Aucun commentaire:

Enregistrer un commentaire