Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/targets/awsLambdaLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ export class AwsLambdaLayerTarget extends BaseTarget {
this.config.layerName,
this.config.license,
artifactBuffer,
awsRegions
awsRegions,
version
);

let publishedLayers = [];
Expand Down Expand Up @@ -316,11 +317,16 @@ export class AwsLambdaLayerTarget extends BaseTarget {

if (!fs.existsSync(baseFilepath)) {
this.logger.warn(`The ${runtime.name} base file is missing.`);
const manifestString = JSON.stringify(runtimeData, undefined, 2) + '\n';
const manifestString =
JSON.stringify(runtimeData, undefined, 2) + '\n';
fs.writeFileSync(newVersionFilepath, manifestString);
} else {
const baseData = JSON.parse(fs.readFileSync(baseFilepath, { encoding: 'utf-8' }).toString());
const manifestString = JSON.stringify({ ...baseData, ...runtimeData }, undefined, 2) + '\n';
const baseData = JSON.parse(
fs.readFileSync(baseFilepath, { encoding: 'utf-8' }).toString()
);
const manifestString =
JSON.stringify({ ...baseData, ...runtimeData }, undefined, 2) +
'\n';
fs.writeFileSync(newVersionFilepath, manifestString);
}

Expand Down
3 changes: 2 additions & 1 deletion src/utils/__tests__/awsLambdaLayerManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ function getTestAwsLambdaLayerManager(): awsManager.AwsLambdaLayerManager {
'test layer name',
'test license',
Buffer.alloc(0),
AWS_TEST_REGIONS
AWS_TEST_REGIONS,
'0.0.0'
);
}

Expand Down
10 changes: 8 additions & 2 deletions src/utils/awsLambdaLayerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,23 @@ export class AwsLambdaLayerManager {
private artifactBuffer: Buffer;
/** Controls if published layers are logged. */
public verboseInfo = true;
/** Version of the SDK. */
private sdkVersion: string;

public constructor(
runtime: CompatibleRuntime,
layerName: string,
license: string,
artifactBuffer: Buffer,
awsRegions: string[]
awsRegions: string[],
sdkVersion: string
) {
this.runtime = runtime;
this.layerName = layerName;
this.license = license;
this.artifactBuffer = artifactBuffer;
this.awsRegions = awsRegions;
this.sdkVersion = sdkVersion;
}

/**
Expand All @@ -75,6 +79,7 @@ export class AwsLambdaLayerManager {
LayerName: this.layerName,
CompatibleRuntimes: this.runtime.versions,
LicenseInfo: this.license,
Description: `Sentry AWS Serverless SDK v${this.sdkVersion}`,
});
await lambda.addLayerVersionPermission({
LayerName: this.layerName,
Expand Down Expand Up @@ -156,7 +161,8 @@ export async function getRegionsFromAws(): Promise<string[]> {
);
}
const data = await response.text();
return new XMLParser().parse(data)
return new XMLParser()
.parse(data)
.DescribeRegionsResponse.regionInfo.item.map(
(region: Region) => region.regionName
)
Expand Down
Loading