functions
Creates, updates, deletes, gets or lists a functions resource.
Overview
| Name | functions |
| Type | Resource |
| Id | aws.appsync.functions |
Fields
The following fields are returned by SELECT queries:
- get_function
- list_functions
| Name | Datatype | Description |
|---|---|---|
name | string | The name of the Function object. (pattern: <code>[_A-Za-z][_0-9A-Za-z]*</code>) |
code | string | The function code that contains the request and response functions. When code is used, the runtime is required. The runtime value must be APPSYNC_JS. |
data_source_name | string | The name of the DataSource. (pattern: <code>[_A-Za-z][_0-9A-Za-z]*</code>) |
description | string | The Function description. |
function_arn | string | The Amazon Resource Name (ARN) of the Function object. |
function_id | string | A unique ID representing the Function object. |
function_version | string | The version of the request mapping template. Currently, only the 2018-05-29 version of the template is supported. |
max_batch_size | integer | The maximum batching size for a resolver. |
request_mapping_template | string | The Function request mapping template. Functions support only the 2018-05-29 version of the request mapping template. (pattern: <code>^.*$</code>) |
response_mapping_template | string | The Function response mapping template. (pattern: <code>^.*$</code>) |
runtime | object | Describes a runtime used by an Amazon Web Services AppSync pipeline resolver or Amazon Web Services AppSync function. Specifies the name and version of the runtime to use. Note that if a runtime is specified, code must also be specified. |
sync_config | object | Describes a Sync configuration for a resolver. Specifies which Conflict Detection strategy and Resolution strategy to use when the resolver is invoked. |
| Name | Datatype | Description |
|---|---|---|
name | string | The name of the Function object. (pattern: <code>[_A-Za-z][_0-9A-Za-z]*</code>) |
code | string | The function code that contains the request and response functions. When code is used, the runtime is required. The runtime value must be APPSYNC_JS. |
data_source_name | string | The name of the DataSource. (pattern: <code>[_A-Za-z][_0-9A-Za-z]*</code>) |
description | string | The Function description. |
function_arn | string | The Amazon Resource Name (ARN) of the Function object. |
function_id | string | A unique ID representing the Function object. |
function_version | string | The version of the request mapping template. Currently, only the 2018-05-29 version of the template is supported. |
max_batch_size | integer | The maximum batching size for a resolver. |
request_mapping_template | string | The Function request mapping template. Functions support only the 2018-05-29 version of the request mapping template. (pattern: <code>^.*$</code>) |
response_mapping_template | string | The Function response mapping template. (pattern: <code>^.*$</code>) |
runtime | object | Describes a runtime used by an Amazon Web Services AppSync pipeline resolver or Amazon Web Services AppSync function. Specifies the name and version of the runtime to use. Note that if a runtime is specified, code must also be specified. |
sync_config | object | Describes a Sync configuration for a resolver. Specifies which Conflict Detection strategy and Resolution strategy to use when the resolver is invoked. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_function | select | api_id, function_id, region | Get a Function. | |
list_functions | select | api_id, region | nextToken, maxResults | List multiple functions. |
create_function | insert | api_id, region, name, dataSourceName | Creates a Function object. A function is a reusable entity. You can use multiple functions to compose the resolver logic. | |
update_function | update | api_id, function_id, region, name, dataSourceName | Updates a Function object. | |
delete_function | delete | api_id, function_id, region | Deletes a Function. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
api_id | string | The GraphQL API ID. |
function_id | string | The Function ID. |
region | string | AWS region (default: us-east-1) |
maxResults | integer | The maximum number of results that you want the request to return. |
nextToken | string | An identifier that was returned from the previous call to this operation, which you can use to return the next set of items in the list. |
SELECT examples
- get_function
- list_functions
Get a Function.
SELECT
name,
code,
data_source_name,
description,
function_arn,
function_id,
function_version,
max_batch_size,
request_mapping_template,
response_mapping_template,
runtime,
sync_config
FROM aws.appsync.functions
WHERE api_id = '{{ api_id }}' -- required
AND function_id = '{{ function_id }}' -- required
AND region = '{{ region }}' -- required
;
List multiple functions.
SELECT
name,
code,
data_source_name,
description,
function_arn,
function_id,
function_version,
max_batch_size,
request_mapping_template,
response_mapping_template,
runtime,
sync_config
FROM aws.appsync.functions
WHERE api_id = '{{ api_id }}' -- required
AND region = '{{ region }}' -- required
AND nextToken = '{{ nextToken }}'
AND maxResults = '{{ maxResults }}'
;
INSERT examples
- create_function
- Manifest
Creates a Function object. A function is a reusable entity. You can use multiple functions to compose the resolver logic.
INSERT INTO aws.appsync.functions (
name,
description,
dataSourceName,
requestMappingTemplate,
responseMappingTemplate,
functionVersion,
syncConfig,
maxBatchSize,
runtime,
code,
api_id,
region
)
SELECT
'{{ name }}' /* required */,
'{{ description }}',
'{{ dataSourceName }}' /* required */,
'{{ requestMappingTemplate }}',
'{{ responseMappingTemplate }}',
'{{ functionVersion }}',
'{{ syncConfig }}',
{{ maxBatchSize }},
'{{ runtime }}',
'{{ code }}',
'{{ api_id }}',
'{{ region }}'
RETURNING
function_configuration
;
# Description fields are for documentation purposes
- name: functions
props:
- name: api_id
value: "{{ api_id }}"
description: Required parameter for the functions resource.
- name: region
value: "{{ region }}"
description: Required parameter for the functions resource.
- name: name
value: "{{ name }}"
- name: description
value: "{{ description }}"
- name: dataSourceName
value: "{{ dataSourceName }}"
- name: requestMappingTemplate
value: "{{ requestMappingTemplate }}"
- name: responseMappingTemplate
value: "{{ responseMappingTemplate }}"
- name: functionVersion
value: "{{ functionVersion }}"
- name: syncConfig
description: |
Describes a Sync configuration for a resolver. Specifies which Conflict Detection strategy and Resolution strategy to use when the resolver is invoked.
value:
conflictHandler: "{{ conflictHandler }}"
conflictDetection: "{{ conflictDetection }}"
lambdaConflictHandlerConfig:
lambdaConflictHandlerArn: "{{ lambdaConflictHandlerArn }}"
- name: maxBatchSize
value: {{ maxBatchSize }}
- name: runtime
description: |
Describes a runtime used by an Amazon Web Services AppSync pipeline resolver or Amazon Web Services AppSync function. Specifies the name and version of the runtime to use. Note that if a runtime is specified, code must also be specified.
value:
name: "{{ name }}"
runtimeVersion: "{{ runtimeVersion }}"
- name: code
value: "{{ code }}"
UPDATE examples
- update_function
Updates a Function object.
UPDATE aws.appsync.functions
SET
name = '{{ name }}',
description = '{{ description }}',
dataSourceName = '{{ dataSourceName }}',
requestMappingTemplate = '{{ requestMappingTemplate }}',
responseMappingTemplate = '{{ responseMappingTemplate }}',
functionVersion = '{{ functionVersion }}',
syncConfig = '{{ syncConfig }}',
maxBatchSize = {{ maxBatchSize }},
runtime = '{{ runtime }}',
code = '{{ code }}'
WHERE
api_id = '{{ api_id }}' --required
AND function_id = '{{ function_id }}' --required
AND region = '{{ region }}' --required
AND name = '{{ name }}' --required
AND dataSourceName = '{{ dataSourceName }}' --required
RETURNING
function_configuration;
DELETE examples
- delete_function
Deletes a Function.
DELETE FROM aws.appsync.functions
WHERE api_id = '{{ api_id }}' --required
AND function_id = '{{ function_id }}' --required
AND region = '{{ region }}' --required
;