Skip to content
v2.273.0

HttpDataSource ​

An AppSync datasource backed by a http endpoint.

Example ​

ts
const api = new appsync.GraphqlApi(this, 'api', {
  name: 'api',
  definition: appsync.Definition.fromFile(path.join(__dirname, 'schema.graphql')),
});

const httpDs = api.addHttpDataSource(
  'ds',
  'https://states.amazonaws.com',
  {
    name: 'httpDsWithStepF',
    description: 'from appsync to StepFunctions Workflow',
    authorizationConfig: {
      signingRegion: 'us-east-1',
      signingServiceName: 'states',
    },
  },
);

httpDs.createResolver('MutationCallStepFunctionResolver', {
  typeName: 'Mutation',
  fieldName: 'callStepFunction',
  requestMappingTemplate: appsync.MappingTemplate.fromFile('request.vtl'),
  responseMappingTemplate: appsync.MappingTemplate.fromFile('response.vtl'),
});
python
api = appsync.GraphqlApi(self, "api",
    name="api",
    definition=appsync.Definition.from_file(path.join(__dirname, "schema.graphql"))
)

http_ds = api.add_http_data_source("ds", "https://states.amazonaws.com",
    name="httpDsWithStepF",
    description="from appsync to StepFunctions Workflow",
    authorization_config=appsync.AwsIamConfig(
        signing_region="us-east-1",
        signing_service_name="states"
    )
)

http_ds.create_resolver("MutationCallStepFunctionResolver",
    type_name="Mutation",
    field_name="callStepFunction",
    request_mapping_template=appsync.MappingTemplate.from_file("request.vtl"),
    response_mapping_template=appsync.MappingTemplate.from_file("response.vtl")
)
java
GraphqlApi api = GraphqlApi.Builder.create(this, "api")
        .name("api")
        .definition(Definition.fromFile(join(__dirname, "schema.graphql")))
        .build();

HttpDataSource httpDs = api.addHttpDataSource("ds", "https://states.amazonaws.com", HttpDataSourceOptions.builder()
        .name("httpDsWithStepF")
        .description("from appsync to StepFunctions Workflow")
        .authorizationConfig(AwsIamConfig.builder()
                .signingRegion("us-east-1")
                .signingServiceName("states")
                .build())
        .build());

httpDs.createResolver("MutationCallStepFunctionResolver", BaseResolverProps.builder()
        .typeName("Mutation")
        .fieldName("callStepFunction")
        .requestMappingTemplate(MappingTemplate.fromFile("request.vtl"))
        .responseMappingTemplate(MappingTemplate.fromFile("response.vtl"))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var api = new GraphqlApi(this, "api", new GraphqlApiProps {
    Name = "api",
    Definition = Definition.FromFile(Join(__dirname, "schema.graphql"))
});

var httpDs = api.AddHttpDataSource("ds", "https://states.amazonaws.com", new HttpDataSourceOptions {
    Name = "httpDsWithStepF",
    Description = "from appsync to StepFunctions Workflow",
    AuthorizationConfig = new AwsIamConfig {
        SigningRegion = "us-east-1",
        SigningServiceName = "states"
    }
});

httpDs.CreateResolver("MutationCallStepFunctionResolver", new BaseResolverProps {
    TypeName = "Mutation",
    FieldName = "callStepFunction",
    RequestMappingTemplate = MappingTemplate.FromFile("request.vtl"),
    ResponseMappingTemplate = MappingTemplate.FromFile("response.vtl")
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
api := appsync.NewGraphqlApi(this, jsii.String("api"), &GraphqlApiProps{
	Name: jsii.String("api"),
	Definition: appsync.Definition_FromFile(path.join(__dirname, jsii.String("schema.graphql"))),
})

httpDs := api.AddHttpDataSource(jsii.String("ds"), jsii.String("https://states.amazonaws.com"), &HttpDataSourceOptions{
	Name: jsii.String("httpDsWithStepF"),
	Description: jsii.String("from appsync to StepFunctions Workflow"),
	AuthorizationConfig: &AwsIamConfig{
		SigningRegion: jsii.String("us-east-1"),
		SigningServiceName: jsii.String("states"),
	},
})

httpDs.CreateResolver(jsii.String("MutationCallStepFunctionResolver"), &BaseResolverProps{
	TypeName: jsii.String("Mutation"),
	FieldName: jsii.String("callStepFunction"),
	RequestMappingTemplate: appsync.MappingTemplate_FromFile(jsii.String("request.vtl")),
	ResponseMappingTemplate: appsync.MappingTemplate_*FromFile(jsii.String("response.vtl")),
})

Initializer ​

ts
new HttpDataSource(scope: Construct, id: string, props: HttpDataSourceProps)
python
HttpDataSource(scope: Construct, id: str, props: HttpDataSourceProps)
java
new HttpDataSource(Construct scope, String id, HttpDataSourceProps props)
csharp
new HttpDataSource(Construct scope, string id, HttpDataSourceProps props)
go
NewHttpDataSource(Scope Construct, Id *string, Props HttpDataSourceProps)

Construct Props ​

The API to attach this data source to.
authorizationConfigAwsIamConfigauthorization_configAwsIamConfigauthorizationConfigAwsIamConfigAuthorizationConfigAwsIamConfigAuthorizationConfigAwsIamConfig= none#
The authorization config in case the HTTP endpoint requires authorization.
descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string= None#
the description of the data source.
endpointstringendpointstrendpointStringEndpointstringEndpoint*stringrequired#
The http endpoint.
metricsConfigDataSourceMetricsConfigmetrics_configDataSourceMetricsConfigmetricsConfigDataSourceMetricsConfigMetricsConfigDataSourceMetricsConfigMetricsConfigDataSourceMetricsConfig= no metrics configuration#
Whether to enable enhanced metrics of the data source Value will be ignored, if `enhancedMetricsConfig.dataSourceLevelMetricsBehavior` on AppSync GraphqlApi construct is set to `FULL_REQUEST_DATA_SOURCE_METRICS`.
namestringnamestrnameStringNamestringName*string= id of data source#
The name of the data source.
serviceRoleIRoleservice_roleIRoleserviceRoleIRoleServiceRoleIRoleServiceRoleIRole= Create a new role#
The IAM service role to be assumed by AppSync to interact with the data source.

Properties ​

the underlying CFN data source resource.
grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipalrequired#
the principal of the data source to be IGrantable.
namestringnamestrnameStringNamestringName*stringrequired#
the name of the data source.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.

Methods ​

createFunction(id: string, props: BaseAppsyncFunctionProps): AppsyncFunctiondef create_function(self, id: str, props: BaseAppsyncFunctionProps) -> AppsyncFunctionpublic AppsyncFunction createFunction(String id, BaseAppsyncFunctionProps props)public AppsyncFunction CreateFunction(string id, BaseAppsyncFunctionProps props)func CreateFunction(Id *string, Props BaseAppsyncFunctionProps) AppsyncFunction#
creates a new appsync function for this datasource and API using the given properties.
createResolver(id: string, props: BaseResolverProps): Resolverdef create_resolver(self, id: str, props: BaseResolverProps) -> Resolverpublic Resolver createResolver(String id, BaseResolverProps props)public Resolver CreateResolver(string id, BaseResolverProps props)func CreateResolver(Id *string, Props BaseResolverProps) Resolver#
creates a new resolver for this datasource and API using the given properties.
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