Skip to content
v2.278.0

CcApiContextQuery Struct ​

Query input for lookup up CloudFormation resources using CC API.

The example below is required to successfully compile CDK (otherwise, the CDK build will generate a synthetic example for the below, but it doesn't have enough type information about the literal string union to generate a validly compiling example).

Example ​

ts
import { CcApiContextQuery } from '@aws-cdk/cloud-assembly-schema';

const x: CcApiContextQuery = {
  typeName: 'AWS::Some::Type',
  expectedMatchCount: 'exactly-one',
  resourceModel: {SomeArn: 'arn:aws:....'},
  propertiesToReturn: ['SomeProp'],
  account: '11111111111',
  region: 'us-east-1',
};
python
from aws_cdk.cloud_assembly_schema import CcApiContextQuery
from aws_cdk.cloud_assembly_schema import CcApiContextQuery


x = CcApiContextQuery(
    type_name="AWS::Some::Type",
    expected_match_count="exactly-one",
    resource_model={"SomeArn": "arn:aws:...."},
    properties_to_return=["SomeProp"],
    account="11111111111",
    region="us-east-1"
)
java
import software.amazon.awscdk.cloudassembly.schema.CcApiContextQuery;


CcApiContextQuery x = CcApiContextQuery.builder()
        .typeName("AWS::Some::Type")
        .expectedMatchCount("exactly-one")
        .resourceModel(Map.of("SomeArn", "arn:aws:...."))
        .propertiesToReturn(List.of("SomeProp"))
        .account("11111111111")
        .region("us-east-1")
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.CloudAssembly.Schema;


var x = new CcApiContextQuery {
    TypeName = "AWS::Some::Type",
    ExpectedMatchCount = "exactly-one",
    ResourceModel = new Dictionary<string, object> { { "SomeArn", "arn:aws:...." } },
    PropertiesToReturn = new [] { "SomeProp" },
    Account = "11111111111",
    Region = "us-east-1"
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/cdklabs/cloud-assembly-schema-go/awscdkcloudassemblyschema"


x := &CcApiContextQuery{
	TypeName: jsii.String("AWS::Some::Type"),
	ExpectedMatchCount: jsii.String("exactly-one"),
	ResourceModel: map[string]interface{}{
		"SomeArn": jsii.String("arn:aws:...."),
	},
	PropertiesToReturn: []*string{
		jsii.String("SomeProp"),
	},
	Account: jsii.String("11111111111"),
	Region: jsii.String("us-east-1"),
}

Properties ​

accountstringaccountstraccountStringAccountstringAccount*string required #
Query account.
assumeRoleAdditionalOptionsoptional{ [key: string]: any }assume_role_additional_optionsoptionaltyping.Mapping[str, Any]assumeRoleAdditionalOptionsoptionalMap<String, Object>AssumeRoleAdditionalOptionsoptionalIDictionary<string, object>AssumeRoleAdditionalOptionsoptional*map[string]interface{} #
Additional options to pass to STS when assuming the lookup role.

Default: No additional options.

  • RoleArn should not be used. Use the dedicated lookupRoleArn property instead.
  • ExternalId should not be used. Use the dedicated lookupRoleExternalId instead.
dummyValueoptionalanydummy_valueoptionalAnydummyValueoptionalObjectDummyValueoptionalobjectDummyValueoptionalinterface{} #
The value to return if the resource was not found and `ignoreErrorOnMissingContext` is true.

Default: No dummy value available

notes

If supplied, dummyValue should be an array of objects.

dummyValue does not have to have elements, and it may have objects with different properties than the properties in propertiesToReturn, but it will be easiest for downstream code if the dummyValue conforms to the expected response shape.

exactIdentifieroptionalstringexact_identifieroptionalstrexactIdentifieroptionalStringExactIdentifieroptionalstringExactIdentifieroptional*string #
Identifier of the resource to look up using `GetResource`.

Default: Either exactIdentifier or propertyMatch should be specified.

Specifying exactIdentifier will return exactly one result, or throw an error unless ignoreErrorOnMissingContext is set.

expectedMatchCountoptionalstringexpected_match_countoptionalstrexpectedMatchCountoptionalStringExpectedMatchCountoptionalstringExpectedMatchCountoptional*string = 'any' #
Expected count of results if `propertyMatch` is specified.
notes

If the expected result count does not match the actual count, by default an error is produced and the result is not committed to cached context, and the user can correct the situation and try again without having to manually clear out the context key using cdk context --remove

If the value of * ignoreErrorOnMissingContext is true, the value of expectedMatchCount is at-least-one | exactly-one and the number of found resources is 0, dummyValue is returned and committed to context instead.

ignoreErrorOnMissingContextoptionalbooleanignore_error_on_missing_contextoptionalboolignoreErrorOnMissingContextoptionalBooleanIgnoreErrorOnMissingContextoptionalboolIgnoreErrorOnMissingContextoptional*bool = false #
Ignore an error and return the `dummyValue` instead if the resource was not found.
notes
  • In case of an exactIdentifier lookup, return the dummyValue if the resource with that identifier was not found.
  • In case of a propertyMatch lookup, return the dummyValue if expectedMatchCount is at-least-one | exactly-one and the number of resources found was 0.

if ignoreErrorOnMissingContext is set, dummyValue should be set and be an array.

lookupRoleArnoptionalstringlookup_role_arnoptionalstrlookupRoleArnoptionalStringLookupRoleArnoptionalstringLookupRoleArnoptional*string = None #
The ARN of the role that should be used to look up the missing values.
lookupRoleExternalIdoptionalstringlookup_role_external_idoptionalstrlookupRoleExternalIdoptionalStringLookupRoleExternalIdoptionalstringLookupRoleExternalIdoptional*string #
The ExternalId that needs to be supplied while assuming this role.

Default: No ExternalId will be supplied

propertiesToReturnstring[]properties_to_returntyping.List[str]propertiesToReturnList<String>PropertiesToReturnstring[]PropertiesToReturn*[]*string required #
This is a set of properties returned from CC API that we want to return from ContextQuery.
notes

If any properties listed here are absent from the target resource, an error will be thrown.

The returned object will always include the key Identifier with the CC-API returned field Identifier.

Notes on property completeness ​

CloudControl API's ListResources may return fewer properties than GetResource would, depending on the resource implementation.

The returned properties here are currently selected from the response object that CloudControl API returns to the CDK CLI.

However, if we find there is need to do so, we may decide to change this behavior in the future: we might change it to perform an additional GetResource call for resources matched by propertyMatch.

propertyMatchoptional{ [key: string]: any }property_matchoptionaltyping.Mapping[str, Any]propertyMatchoptionalMap<String, Object>PropertyMatchoptionalIDictionary<string, object>PropertyMatchoptional*map[string]interface{} #
Returns any resources matching these properties, using `ListResources`.

Default: Either exactIdentifier or propertyMatch should be specified.

notes

By default, specifying propertyMatch will successfully return 0 or more results. To throw an error if the number of results is unexpected (and prevent the query results from being committed to context), specify expectedMatchCount.

Notes on property completeness ​

CloudControl API's ListResources may return fewer properties than GetResource would, depending on the resource implementation.

The resources that propertyMatch matches against will only ever be the properties returned by the ListResources call.

regionstringregionstrregionStringRegionstringRegion*string required #
Query region.
resourceModeloptional{ [key: string]: any }resource_modeloptionaltyping.Mapping[str, Any]resourceModeloptionalMap<String, Object>ResourceModeloptionalIDictionary<string, object>ResourceModeloptional*map[string]interface{} #
The resource model to use to select the resources, using `ListResources`..

Default: no resource Model is provided

This is needed for sub-resources where the parent Arn is required.

See https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations-list.html#resource-operations-list-containers

typeNamestringtype_namestrtypeNameStringTypeNamestringTypeName*string required #
The CloudFormation resource type.