Skip to content
v2.274.0

AppSyncHttpDataSource ​

An AppSync datasource backed by a http endpoint.

Example ​

ts
import * as apigw from 'aws-cdk-lib/aws-apigateway';

const api = new appsync.EventApi(this, 'EventApiHttp', {
  apiName: 'HttpEventApi',
});

const randomApi = new apigw.RestApi(this, 'RandomApi');
const randomRoute = randomApi.root.addResource('random');
randomRoute.addMethod('GET', new apigw.MockIntegration({
  integrationResponses: [{
    statusCode: '200',
    responseTemplates: {
      'application/json': 'my-random-value',
    },
  }],
  passthroughBehavior: apigw.PassthroughBehavior.NEVER,
  requestTemplates: {
    'application/json': '{ "statusCode": 200 }',
  },
}), {
  methodResponses: [{ statusCode: '200' }],
});

const dataSource = api.addHttpDataSource('httpsource', `https://${randomApi.restApiId}.execute-api.${this.region}.amazonaws.com`);
python
import aws_cdk.aws_apigateway as apigw


api = appsync.EventApi(self, "EventApiHttp",
    api_name="HttpEventApi"
)

random_api = apigw.RestApi(self, "RandomApi")
random_route = random_api.root.add_resource("random")
random_route.add_method("GET", apigw.MockIntegration(
    integration_responses=[apigw.IntegrationResponse(
        status_code="200",
        response_templates={
            "application/json": "my-random-value"
        }
    )],
    passthrough_behavior=apigw.PassthroughBehavior.NEVER,
    request_templates={
        "application/json": "{ \"statusCode\": 200 }"
    }
),
    method_responses=[apigw.MethodResponse(status_code="200")]
)

data_source = api.add_http_data_source("httpsource", f"https://{randomApi.restApiId}.execute-api.{this.region}.amazonaws.com")
java
import software.amazon.awscdk.services.apigateway.*;


EventApi api = EventApi.Builder.create(this, "EventApiHttp")
        .apiName("HttpEventApi")
        .build();

RestApi randomApi = new RestApi(this, "RandomApi");
Resource randomRoute = randomApi.root.addResource("random");
randomRoute.addMethod("GET", MockIntegration.Builder.create()
        .integrationResponses(List.of(IntegrationResponse.builder()
                .statusCode("200")
                .responseTemplates(Map.of(
                        "application/json", "my-random-value"))
                .build()))
        .passthroughBehavior(PassthroughBehavior.NEVER)
        .requestTemplates(Map.of(
                "application/json", "{ \"statusCode\": 200 }"))
        .build(), MethodOptions.builder()
        .methodResponses(List.of(MethodResponse.builder().statusCode("200").build()))
        .build());

AppSyncHttpDataSource dataSource = api.addHttpDataSource("httpsource", String.format("https://%s.execute-api.%s.amazonaws.com", randomApi.getRestApiId(), this.region));
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.APIGateway;


var api = new EventApi(this, "EventApiHttp", new EventApiProps {
    ApiName = "HttpEventApi"
});

var randomApi = new RestApi(this, "RandomApi");
var randomRoute = randomApi.Root.AddResource("random");
randomRoute.AddMethod("GET", new MockIntegration(new IntegrationOptions {
    IntegrationResponses = new [] { new IntegrationResponse {
        StatusCode = "200",
        ResponseTemplates = new Dictionary<string, string> {
            { "application/json", "my-random-value" }
        }
    } },
    PassthroughBehavior = PassthroughBehavior.NEVER,
    RequestTemplates = new Dictionary<string, string> {
        { "application/json", "{ \"statusCode\": 200 }" }
    }
}), new MethodOptions {
    MethodResponses = new [] { new MethodResponse { StatusCode = "200" } }
});

var dataSource = api.AddHttpDataSource("httpsource", $"https://{randomApi.restApiId}.execute-api.{this.region}.amazonaws.com");
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"


api := appsync.NewEventApi(this, jsii.String("EventApiHttp"), &EventApiProps{
	ApiName: jsii.String("HttpEventApi"),
})

randomApi := apigw.NewRestApi(this, jsii.String("RandomApi"))
randomRoute := randomApi.Root.AddResource(jsii.String("random"))
randomRoute.AddMethod(jsii.String("GET"), apigw.NewMockIntegration(&IntegrationOptions{
	IntegrationResponses: []IntegrationResponse{
		&IntegrationResponse{
			StatusCode: jsii.String("200"),
			ResponseTemplates: map[string]*string{
				"application/json": jsii.String("my-random-value"),
			},
		},
	},
	PassthroughBehavior: apigw.PassthroughBehavior_NEVER,
	RequestTemplates: map[string]*string{
		"application/json": jsii.String("{ \"statusCode\": 200 }"),
	},
}), &MethodOptions{
	MethodResponses: []MethodResponse{
		&MethodResponse{
			StatusCode: jsii.String("200"),
		},
	},
})

dataSource := api.AddHttpDataSource(jsii.String("httpsource"), fmt.Sprintf("https://%v.execute-api.%v.amazonaws.com", randomApi.RestApiId, this.Region))

Initializer ​

ts
new AppSyncHttpDataSource(scope: Construct, id: string, props: AppSyncHttpDataSourceProps)
python
AppSyncHttpDataSource(scope: Construct, id: str, props: AppSyncHttpDataSourceProps)
java
new AppSyncHttpDataSource(Construct scope, String id, AppSyncHttpDataSourceProps props)
csharp
new AppSyncHttpDataSource(Construct scope, string id, AppSyncHttpDataSourceProps props)
go
NewAppSyncHttpDataSource(Scope Construct, Id *string, Props AppSyncHttpDataSourceProps)

Construct Props ​

The API to attach this data source to.
authorizationConfigoptionalAppSyncAwsIamConfigauthorization_configoptionalAppSyncAwsIamConfigauthorizationConfigoptionalAppSyncAwsIamConfigAuthorizationConfigoptionalAppSyncAwsIamConfigAuthorizationConfigoptionalAppSyncAwsIamConfig= none#
The authorization config in case the HTTP endpoint requires authorization.
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string= None#
The description of the data source.
endpointstringendpointstrendpointStringEndpointstringEndpoint*stringrequired#
The http endpoint.
nameoptionalstringnameoptionalstrnameoptionalStringNameoptionalstringNameoptional*string#
The name of the data source.

Default: id of data source

The only allowed pattern is: {[_A-Za-z][_0-9A-Za-z]*}. Any invalid characters will be automatically removed.

serviceRoleoptionalIRoleservice_roleoptionalIRoleserviceRoleoptionalIRoleServiceRoleoptionalIRoleServiceRoleoptionalIRole#
The IAM service role to be assumed by AppSync to interact with the data source.

Default: Create a new role

Properties ​

grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipal#
The principal of the data source to be IGrantable.
namestringnamestrnameStringNamestringName*string#
The name of the data source.
nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
The underlying CFN data source resource.

Methods ​

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining