Description
Expected Behaviour
Based on the discussion had in aws-powertools/powertools-lambda-python#1796 when working with AppConfig, the transforms JSON & binary should respectively return an object and a string, i.e.
const configProfileFeatureFlag = new CfnConfigurationProfile(this, "configProfileFeatureFlag", {
name: "test-config-profile-feature-flag",
applicationId: application.ref,
locationUri: "hosted",
type: "AWS.AppConfig.FeatureFlags",
});
const configVersionFeatureFlag = new CfnHostedConfigurationVersion(this, "configVersionFeatureFlag", {
applicationId: application.ref,
configurationProfileId: configProfileFeatureFlag.ref,
contentType: 'application/json',
content: JSON.stringify({
"version": "1",
"flags": {
myFeatureFlag: {
name: "myFeatureFlag",
}
},
values: {
myFeatureFlag: {
enabled: true,
}
}
}),
});
when retrieved with await getAppConfig('my-feature-flag', { transform: 'json' });
, should return:
"myFeatureFlag": {
"enabled": true,
}
while:
const configProfilePlainText = new CfnConfigurationProfile(this, "configProfilePlainText", {
name: "test-config-profile-plain-text",
applicationId: application.ref,
locationUri: "hosted",
type: "AWS.Freeform",
});
// Base64-encoded value
const value = toBase64(new TextEncoder().encode('test'));
const configVersionPlainText = new CfnHostedConfigurationVersion(this, "configVersionPlainText", {
applicationId: application.ref,
configurationProfileId: configProfilePlainText.ref,
content: value,
contentType: "text/plain",
});
when retrieved with await getAppConfig('my-feature-flag', { transform: 'binary' });
, should return test
.
Essentially, the provider and transformer should transparently handle the fact that AppConfig always returns an Uint8Array
and subsequently apply the transform when one is provided.
Current Behaviour
Currently the transformer would decode the binary only when transform: "binary"
is specified and when doing so it would skip the base64 decoding.
This would also result in never being able to use the JSON transform because when attempting to parse the JSON the value was still a binary.
Code snippet
See above.
Possible Solution
No response
Steps to Reproduce
See above as well as linked discussion/isssue.
AWS Lambda Powertools for TypeScript version
latest
AWS Lambda function runtime
18.x
Packaging format used
Npm
Execution logs
No response