def add_service_discovery_api(self, rest_api: apigateway.RestApi): well_known = self.add_resource( apigateway.Resource( 'Apiwellknown', RestApiId=Ref(rest_api), PathPart='.well-known', ParentId=GetAtt(rest_api, 'RootResourceId'), )) terraform_json = self.add_resource( apigateway.Resource('Apiwellknownterraformjson', RestApiId=Ref(rest_api), PathPart='terraform.json', ParentId=Ref(well_known))) service_discovery = self.add_resource( apigateway.Method( 'GETwellknownterraformjson', RestApiId=Ref(rest_api), ResourceId=Ref(terraform_json), AuthorizationType='NONE', HttpMethod='GET', Integration=apigateway.Integration( 'GETwellknownterraformjsonIntegration', Type='MOCK', IntegrationResponses=[ apigateway.IntegrationResponse( StatusCode='200', ResponseTemplates={ 'application/json': json.dumps({'modules.v1': '/v1/'}) }) ], RequestTemplates={ 'application/json': json.dumps({'statusCode': 200}) }, ), MethodResponses=[ apigateway.MethodResponse( StatusCode='200', ResponseModels={'application/json': 'Empty'}) ])) return service_discovery
Description="GDACK Function", Handler="index.handler", Role=GetAtt(lambdaRole, "Arn"), Runtime="python3.6", MemorySize=128, Timeout="180" )) restApi = t.add_resource(api.RestApi( "restApi", Name="GDACK" )) apiResource = t.add_resource(api.Resource( "apiResource", RestApiId=Ref(restApi), PathPart="{proxy+}", ParentId=GetAtt(restApi, "RootResourceId"), )) apiMethod = t.add_resource(api.Method( "apiMethod", DependsOn='lambdaFunction', RestApiId=Ref(restApi), AuthorizationType="NONE", ResourceId=Ref(apiResource), HttpMethod="ANY", Integration=api.Integration( Credentials=GetAtt(apiRole, "Arn"), Type="AWS_PROXY", IntegrationHttpMethod='ANY', Uri=Join("", [
def add_registry_api(self, rest_api: apigateway.RestApi): v1 = self.add_resource( apigateway.Resource( 'Apiv1', RestApiId=Ref(rest_api), PathPart='v1', ParentId=GetAtt(rest_api, 'RootResourceId'), )) download_redirect = self.add_resource( apigateway.Resource( 'DownloadRedirect', RestApiId=Ref(rest_api), PathPart='download.tar.gz', ParentId=GetAtt(rest_api, 'RootResourceId'), )) namespace = self.add_resource( apigateway.Resource( 'ApiNamespace', RestApiId=Ref(rest_api), PathPart='{namespace}', ParentId=Ref(v1), )) name = self.add_resource( apigateway.Resource( 'ApiName', RestApiId=Ref(rest_api), PathPart='{name}', ParentId=Ref(namespace), )) provider = self.add_resource( apigateway.Resource( 'ApiProvider', RestApiId=Ref(rest_api), PathPart='{provider}', ParentId=Ref(name), )) version = self.add_resource( apigateway.Resource( 'ApiVersion', RestApiId=Ref(rest_api), PathPart='{version}', ParentId=Ref(provider), )) download = self.add_resource( apigateway.Resource( 'ApiDownload', RestApiId=Ref(rest_api), PathPart='download', ParentId=Ref(version), )) upload = self.add_resource( apigateway.Resource( 'ApiUpload', RestApiId=Ref(rest_api), PathPart='upload', ParentId=Ref(version), )) def add_method(resource, method='GET'): return self.add_resource( apigateway.Method( f'{method}{resource.title}', RestApiId=Ref(rest_api), ResourceId=Ref(resource), AuthorizationType='NONE', HttpMethod=method, Integration=apigateway.Integration( f'{method}{resource.title}Integration', Type='AWS_PROXY', Uri=Join('', [ 'arn:aws:apigateway:', Region, ':lambda:path/2015-03-31/functions/', Ref(self._lambda_function), '/invocations' ]), IntegrationHttpMethod='POST'))) return [ add_method(x) for x in [version, download, download_redirect, upload] ] + [add_method(upload, 'PUT')]
api_lambda_permission = template.add_resource( awslambda.Permission("APILambdaPermission", Action="lambda:InvokeFunction", FunctionName=Ref(lambda_function), Principal="apigateway.amazonaws.com", SourceArn=Join("", [ "arn:aws:execute-api:", Ref("AWS::Region"), ":", Ref("AWS::AccountId"), ":", Ref(api), "/*/GET/*" ]))) api_first_resource = template.add_resource( apigateway.Resource("APIFirstResource", ParentId=GetAtt(api, "RootResourceId"), PathPart="{param1}", RestApiId=Ref(api))) api_first_method = template.add_resource( apigateway.Method( "APIFirstResourceMethodGET", ApiKeyRequired=False, AuthorizationType="NONE", HttpMethod="GET", ResourceId=Ref(api_first_resource), RestApiId=Ref(api), Integration=apigateway.Integration( Type="AWS", IntegrationHttpMethod="POST", Uri=Join("", [ "arn:aws:apigateway:",
])) devices_authorizer = template.add_resource( apigateway.Authorizer( 'DevicesApiAuthorizer', RestApiId=Ref(restapi), Name='DevicesApiAuthorizer', Type='REQUEST', AuthorizerResultTtlInSeconds=0, AuthorizerCredentials=GetAtt(authorizer_credentials, "Arn"), IdentitySource="method.request.header.Attestation", AuthorizerUri=lambda_invocation_arn(authorizer_lambda))) android_resource = template.add_resource( apigateway.Resource('AndroidResource', RestApiId=Ref(restapi), PathPart='android', ParentId=GetAtt(restapi, 'RootResourceId'))) root_method = template.add_resource( apigateway.Method('RootMethod', RestApiId=Ref(restapi), ResourceId=GetAtt(restapi, 'RootResourceId'), HttpMethod='POST', AuthorizationType='CUSTOM', AuthorizerId=Ref(devices_authorizer), Integration=apigateway.Integration( Type='MOCK', IntegrationHttpMethod='POST', ))) android_register_resource = template.add_resource(