Ejemplo n.º 1
0
 public MyStack()
 {
     var testRestApi = new Aws.ApiGateway.RestApi("testRestApi", new Aws.ApiGateway.RestApiArgs
     {
         Description = "This is my API for demonstration purposes",
     });
     var testDeployment = new Aws.ApiGateway.Deployment("testDeployment", new Aws.ApiGateway.DeploymentArgs
     {
         RestApi   = testRestApi.Id,
         StageName = "dev",
     }, new CustomResourceOptions
     {
         DependsOn =
         {
             "aws_api_gateway_integration.test",
         },
     });
     var testStage = new Aws.ApiGateway.Stage("testStage", new Aws.ApiGateway.StageArgs
     {
         Deployment = testDeployment.Id,
         RestApi    = testRestApi.Id,
         StageName  = "prod",
     });
     var testResource = new Aws.ApiGateway.Resource("testResource", new Aws.ApiGateway.ResourceArgs
     {
         ParentId = testRestApi.RootResourceId,
         PathPart = "mytestresource",
         RestApi  = testRestApi.Id,
     });
     var testMethod = new Aws.ApiGateway.Method("testMethod", new Aws.ApiGateway.MethodArgs
     {
         Authorization = "NONE",
         HttpMethod    = "GET",
         ResourceId    = testResource.Id,
         RestApi       = testRestApi.Id,
     });
     var methodSettings = new Aws.ApiGateway.MethodSettings("methodSettings", new Aws.ApiGateway.MethodSettingsArgs
     {
         MethodPath = Output.Tuple(testResource.PathPart, testMethod.HttpMethod).Apply(values =>
         {
             var pathPart   = values.Item1;
             var httpMethod = values.Item2;
             return($"{pathPart}/{httpMethod}");
         }),
         RestApi  = testRestApi.Id,
         Settings = new Aws.ApiGateway.Inputs.MethodSettingsSettingsArgs
         {
             LoggingLevel   = "INFO",
             MetricsEnabled = true,
         },
         StageName = testStage.StageName,
     });
     var testIntegration = new Aws.ApiGateway.Integration("testIntegration", new Aws.ApiGateway.IntegrationArgs
     {
         HttpMethod = testMethod.HttpMethod,
         ResourceId = testResource.Id,
         RestApi    = testRestApi.Id,
         Type       = "MOCK",
     });
 }
Ejemplo n.º 2
0
 public MyStack()
 {
     var myDemoAPI = new Aws.ApiGateway.RestApi("myDemoAPI", new Aws.ApiGateway.RestApiArgs
     {
         Description = "This is my API for demonstration purposes",
     });
     var myDemoResource = new Aws.ApiGateway.Resource("myDemoResource", new Aws.ApiGateway.ResourceArgs
     {
         ParentId = myDemoAPI.RootResourceId,
         PathPart = "mydemoresource",
         RestApi  = myDemoAPI.Id,
     });
     var myDemoMethod = new Aws.ApiGateway.Method("myDemoMethod", new Aws.ApiGateway.MethodArgs
     {
         Authorization = "NONE",
         HttpMethod    = "GET",
         ResourceId    = myDemoResource.Id,
         RestApi       = myDemoAPI.Id,
     });
     var myDemoIntegration = new Aws.ApiGateway.Integration("myDemoIntegration", new Aws.ApiGateway.IntegrationArgs
     {
         HttpMethod = myDemoMethod.HttpMethod,
         ResourceId = myDemoResource.Id,
         RestApi    = myDemoAPI.Id,
         Type       = "MOCK",
     });
     var response200 = new Aws.ApiGateway.MethodResponse("response200", new Aws.ApiGateway.MethodResponseArgs
     {
         HttpMethod = myDemoMethod.HttpMethod,
         ResourceId = myDemoResource.Id,
         RestApi    = myDemoAPI.Id,
         StatusCode = "200",
     });
 }
Ejemplo n.º 3
0
    public MyStack()
    {
        var myDemoAPI = new Aws.ApiGateway.RestApi("myDemoAPI", new Aws.ApiGateway.RestApiArgs
        {
            Description = "This is my API for demonstration purposes",
        });
        var myDemoResource = new Aws.ApiGateway.Resource("myDemoResource", new Aws.ApiGateway.ResourceArgs
        {
            ParentId = myDemoAPI.RootResourceId,
            PathPart = "mydemoresource",
            RestApi  = myDemoAPI.Id,
        });
        var myDemoMethod = new Aws.ApiGateway.Method("myDemoMethod", new Aws.ApiGateway.MethodArgs
        {
            Authorization = "NONE",
            HttpMethod    = "GET",
            ResourceId    = myDemoResource.Id,
            RestApi       = myDemoAPI.Id,
        });
        var myDemoIntegration = new Aws.ApiGateway.Integration("myDemoIntegration", new Aws.ApiGateway.IntegrationArgs
        {
            HttpMethod = myDemoMethod.HttpMethod,
            ResourceId = myDemoResource.Id,
            RestApi    = myDemoAPI.Id,
            Type       = "MOCK",
        });
        var response200 = new Aws.ApiGateway.MethodResponse("response200", new Aws.ApiGateway.MethodResponseArgs
        {
            HttpMethod = myDemoMethod.HttpMethod,
            ResourceId = myDemoResource.Id,
            RestApi    = myDemoAPI.Id,
            StatusCode = "200",
        });
        var myDemoIntegrationResponse = new Aws.ApiGateway.IntegrationResponse("myDemoIntegrationResponse", new Aws.ApiGateway.IntegrationResponseArgs
        {
            HttpMethod        = myDemoMethod.HttpMethod,
            ResourceId        = myDemoResource.Id,
            ResponseTemplates =
            {
                { "application/xml", @"#set($inputRoot = $input.path('$'))
<?xml version=""1.0"" encoding=""UTF-8""?>
<message>
    $inputRoot.body
</message>

" },
            },
            RestApi    = myDemoAPI.Id,
            StatusCode = response200.StatusCode,
        });
    }
Ejemplo n.º 4
0
    public MyStack()
    {
        var myDemoAPI = new Aws.ApiGateway.RestApi("myDemoAPI", new Aws.ApiGateway.RestApiArgs
        {
            Description = "This is my API for demonstration purposes",
        });
        var myDemoResource = new Aws.ApiGateway.Resource("myDemoResource", new Aws.ApiGateway.ResourceArgs
        {
            ParentId = myDemoAPI.RootResourceId,
            PathPart = "mydemoresource",
            RestApi  = myDemoAPI.Id,
        });
        var myDemoMethod = new Aws.ApiGateway.Method("myDemoMethod", new Aws.ApiGateway.MethodArgs
        {
            Authorization = "NONE",
            HttpMethod    = "GET",
            ResourceId    = myDemoResource.Id,
            RestApi       = myDemoAPI.Id,
        });
        var myDemoIntegration = new Aws.ApiGateway.Integration("myDemoIntegration", new Aws.ApiGateway.IntegrationArgs
        {
            CacheKeyParameters =
            {
                "method.request.path.param",
            },
            CacheNamespace    = "foobar",
            HttpMethod        = myDemoMethod.HttpMethod,
            RequestParameters =
            {
                { "integration.request.header.X-Authorization", "'static'" },
            },
            RequestTemplates =
            {
                { "application/xml", @"{
   ""body"" : $input.json('$')
}

" },
            },
            ResourceId          = myDemoResource.Id,
            RestApi             = myDemoAPI.Id,
            TimeoutMilliseconds = 29000,
            Type = "MOCK",
        });
    }
Ejemplo n.º 5
0
 public MyStack()
 {
     var myDemoAPI = new Aws.ApiGateway.RestApi("myDemoAPI", new Aws.ApiGateway.RestApiArgs
     {
         Description = "This is my API for demonstration purposes",
     });
     var myDemoResource = new Aws.ApiGateway.Resource("myDemoResource", new Aws.ApiGateway.ResourceArgs
     {
         RestApi  = myDemoAPI.Id,
         ParentId = myDemoAPI.RootResourceId,
         PathPart = "test",
     });
     var myDemoMethod = new Aws.ApiGateway.Method("myDemoMethod", new Aws.ApiGateway.MethodArgs
     {
         RestApi       = myDemoAPI.Id,
         ResourceId    = myDemoResource.Id,
         HttpMethod    = "GET",
         Authorization = "NONE",
     });
     var myDemoIntegration = new Aws.ApiGateway.Integration("myDemoIntegration", new Aws.ApiGateway.IntegrationArgs
     {
         RestApi    = myDemoAPI.Id,
         ResourceId = myDemoResource.Id,
         HttpMethod = myDemoMethod.HttpMethod,
         Type       = "MOCK",
     });
     var myDemoDeployment = new Aws.ApiGateway.Deployment("myDemoDeployment", new Aws.ApiGateway.DeploymentArgs
     {
         RestApi   = myDemoAPI.Id,
         StageName = "test",
         Variables =
         {
             { "answer", "42" },
         },
     }, new CustomResourceOptions
     {
         DependsOn =
         {
             myDemoIntegration,
         },
     });
 }