AppSyncHttpDataSource
An AppSync datasource backed by a http endpoint.
Example
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`);
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")
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));
// 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");
// 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
new AppSyncHttpDataSource(scope: Construct, id: string, props: AppSyncHttpDataSourceProps)
AppSyncHttpDataSource(scope: Construct, id: str, props: AppSyncHttpDataSourceProps)
new AppSyncHttpDataSource(Construct scope, String id, AppSyncHttpDataSourceProps props)
new AppSyncHttpDataSource(Construct scope, string id, AppSyncHttpDataSourceProps props)
NewAppSyncHttpDataSource(Scope Construct, Id *string, Props AppSyncHttpDataSourceProps)
Construct Props
authorizationConfigoptionalAppSyncAwsIamConfigauthorization_configoptionalAppSyncAwsIamConfigauthorizationConfigoptionalAppSyncAwsIamConfigAuthorizationConfigoptionalAppSyncAwsIamConfigAuthorizationConfigoptionalAppSyncAwsIamConfig= none#descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string= None#Default: id of data source
The only allowed pattern is: {[_A-Za-z][_0-9A-Za-z]*}. Any invalid characters will be automatically removed.
Properties
grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipal#resourceCfnDataSourceresourceCfnDataSourceresourceCfnDataSourceResourceCfnDataSourceResourceCfnDataSource#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#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#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#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