Class GetContextValueOptions
Inherited Members
Namespace: Amazon.CDK
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class GetContextValueOptions : IGetContextValueOptions, IGetContextKeyOptions
Syntax (vb)
Public Class GetContextValueOptions Implements IGetContextValueOptions, IGetContextKeyOptions
Remarks
ExampleMetadata: fixture=_generated
Examples
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
var dummyValue;
var props;
var getContextValueOptions = new GetContextValueOptions {
DummyValue = dummyValue,
Provider = "provider",
// the properties below are optional
AdditionalCacheKey = "additionalCacheKey",
IgnoreErrorOnMissingContext = false,
IncludeEnvironment = false,
MustExist = false,
Props = new Dictionary<string, object> {
{ "propsKey", props }
}
};
Synopsis
Constructors
| GetContextValueOptions() |
Properties
| AdditionalCacheKey | Adds an additional discriminator to the |
| DummyValue | The value to return if the lookup has not yet been performed. |
| IgnoreErrorOnMissingContext | (deprecated) Ignore a lookup failure and return the |
| IncludeEnvironment | Whether to include the stack's account and region automatically. |
| MustExist | Whether the resource must exist. |
| Props | Provider-specific properties. |
| Provider | The context provider to query. |
Constructors
GetContextValueOptions()
public GetContextValueOptions()
Remarks
ExampleMetadata: fixture=_generated
Examples
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
var dummyValue;
var props;
var getContextValueOptions = new GetContextValueOptions {
DummyValue = dummyValue,
Provider = "provider",
// the properties below are optional
AdditionalCacheKey = "additionalCacheKey",
IgnoreErrorOnMissingContext = false,
IncludeEnvironment = false,
MustExist = false,
Props = new Dictionary<string, object> {
{ "propsKey", props }
}
};
Properties
AdditionalCacheKey
Adds an additional discriminator to the cdk.context.json cache key.
public string? AdditionalCacheKey { get; set; }
Property Value
Remarks
Default: - no additional cache key
DummyValue
The value to return if the lookup has not yet been performed.
public object DummyValue { get; set; }
Property Value
Remarks
Upon first synthesis, the lookups has not yet been performed. The
getValue() operation returns this value instead, so that synthesis can
proceed. After synthesis completes the first time, the actual lookup will
be performed and synthesis will run again with the real value.
Dummy values should preferably have valid shapes so that downstream consumers of lookup values don't throw validation exceptions if they encounter a dummy value (or all possible downstream consumers need to effectively check for the well-known shape of the dummy value); throwing an exception would error out the synthesis operation and prevent the lookup and the second, real, synthesis from happening.
Connection to mustExist
dummyValue is also used as the official value to return if the lookup has
failed and mustExist == false.
IgnoreErrorOnMissingContext
(deprecated) Ignore a lookup failure and return the dummyValue instead.
[Obsolete("Use mustExist instead")]
public bool? IgnoreErrorOnMissingContext { get; set; }
Property Value
bool?
Remarks
mustExist is the recommended alias for this deprecated
property (note that its value is reversed).
Default: false
Stability: Deprecated
IncludeEnvironment
Whether to include the stack's account and region automatically.
public bool? IncludeEnvironment { get; set; }
Property Value
bool?
Remarks
Default: true
MustExist
Whether the resource must exist.
public bool? MustExist { get; set; }
Property Value
bool?
Remarks
If this is set (the default), the query fails if the value or resource we tried to look up doesn't exist.
If this is false and the value we tried to look up could not be found, the
failure is suppressed and dummyValue is officially returned instead.
When this happens, dummyValue is encoded into cached context and it will
never be refreshed anymore until the user runs cdk context --reset <key>.
Note that it is not possible for the CDK app code to make a distinction between "the lookup has not been performed yet" and "the lookup didn't find anything and we returned a default value instead".
Context providers
This feature must explicitly be supported by context providers. It is currently supported by:
Note to implementors
The dummy value should not be returned for all SDK lookup failures. For example, "no network" or "no credentials" or "malformed query" should not lead to the dummy value being returned. Only the case of "no such resource" should.
Default: true
Props
Provider-specific properties.
public IDictionary<string, object>? Props { get; set; }
Property Value
Remarks
ExampleMetadata: fixture=_generated
Provider
The context provider to query.
public string Provider { get; set; }
Property Value
Remarks
ExampleMetadata: fixture=_generated