Skip to content
Merged
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
43 changes: 33 additions & 10 deletions docs/lambda-selector/lambda-attributes-selector.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,25 @@
column-gap: 5px;
}

[role="select-input"]{
[role="select-input"] {
border: none;
margin-left: 1px;
color: #2b4590;
font-weight: bold;
border-radius: 5px;
}

[role="lambda-selector-header"]{
[role="lambda-selector-header"] {
align-self: flex-start;
}

#fallback-extension-arn-selector-section {
display: none;
}

#fallback-agent-arn-selector-section {
display: none;
}
</style>

<script>
Expand All @@ -61,16 +69,15 @@ const addArnGenerator = async (type, ghRepo, arnPattern) => {
tab.innerHTML = tab.innerHTML.replace(rgx, `<span role="replace${type}Arn"></span>`);
});

var version = "ver-1-0-0";
var version = undefined;
var releaseArns = [];

const retrieveLatestLayerVersion = async () => {
const releases = await fetch(`https://api.github.com/repos/elastic/${ghRepo}/releases`).then(data => {
return data.json();
return data.status >= 400 ? undefined : data.json();
});

releases.filter(release => !release.draft && release.body.includes('arn:aws:lambda:'));


if(releases){
var latestRelease = releases[0];

releases.forEach(release => {
Expand All @@ -82,11 +89,25 @@ const addArnGenerator = async (type, ghRepo, arnPattern) => {
releaseArns = latestRelease.body.match(layerArnPattern);

version = latestRelease.tag_name.replace("v","ver-").replace(/\./g, '-');
} else {
document.getElementById("default-arn-selector-section").style.display = "none";
const fallbackSection = document.getElementById(`fallback-${type}-arn-selector-section`);
if(fallbackSection){
fallbackSection.innerHTML = fallbackSection.innerHTML.replace(/RELEASE_LINK/, `https://github.com/elastic/${ghRepo}/releases/latest`);
fallbackSection.style.display = "block";
}
}
};

const updateARN = (region, arch) => {
const arnWithoutLayerVersion = arnPattern.replace(/\$\{region\}/, region).replace(/\$\{arch\}/, arch).replace(/\$\{version\}/, version);
const arn = releaseArns.length === 0 ? arnWithoutLayerVersion + ':1' : releaseArns.find(a => a.startsWith(arnWithoutLayerVersion));
var arn = `&lt;SELECTED_${type.toUpperCase()}_LAYER_ARN&gt;`;
if(version && releaseArns.length > 0){
const arnWithoutLayerVersion = arnPattern.replace(/\$\{region\}/, region).replace(/\$\{arch\}/, arch).replace(/\$\{version\}/, version);
const lookedUpArn = releaseArns.find(a => a.startsWith(arnWithoutLayerVersion));
if(lookedUpArn){
arn = lookedUpArn;
}
}
document.querySelectorAll(`[role="replace${type}Arn"]`).forEach(span => {
span.innerHTML = arn;
});
Expand All @@ -106,7 +127,9 @@ window.addEventListener("DOMContentLoaded", async () => {
});
</script>

<div role="lambda-selector">
<p id="fallback-extension-arn-selector-section">Pick the right ARN from <a target="_bkank" href="RELEASE_LINK">this release table for the APM Lambda Extension Layer</a>.</p>
<p id="fallback-agent-arn-selector-section">In addition, pick the right ARN from <a target="_bkank" href="RELEASE_LINK">this release table for the APM Agent Layer</a>.</p>
Comment on lines +130 to +131
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p id="fallback-extension-arn-selector-section">Pick the right ARN from <a target="_bkank" href="RELEASE_LINK">this release table for the APM Lambda Extension Layer</a>.</p>
<p id="fallback-agent-arn-selector-section">In addition, pick the right ARN from <a target="_bkank" href="RELEASE_LINK">this release table for the APM Agent Layer</a>.</p>
<p id="fallback-extension-arn-selector-section">Pick the right ARN from <a target="_blank" href="RELEASE_LINK">this release table for the APM Lambda Extension Layer</a>.</p>
<p id="fallback-agent-arn-selector-section">In addition, pick the right ARN from <a target="_blank" href="RELEASE_LINK">this release table for the APM Agent Layer</a>.</p>

Were these intended to be target="_blank"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed on main in d0f03e7.

<div id="default-arn-selector-section" role="lambda-selector">
<div role="lambda-selector-header">Select the AWS region and architecture of your Lambda function. This documentation will update based on your selections.</div>
<div role="lambda-selector-content">
<div role="lambda-selector-input">
Expand Down