in frontend/src/pages/Configure/Cluster.js [190:249]
function CustomAMISettings() {
const editing = useState(['app', 'wizard', 'editing']);
const customImages = useState(['app', 'wizard', 'customImages']) || [];
const officialImages = useState(['app', 'wizard', 'officialImages']) || [];
const error = useState([...errorsPath, 'customAmi']);
const customAmiPath = ['app', 'wizard', 'config', 'Image', 'CustomAmi'];
const customAmi = useState(customAmiPath);
const customAmiEnabled = useState(['app', 'wizard', 'customAMI', 'enabled']) || false;
const osPath = ['app', 'wizard', 'config', 'Image', 'Os'];
const os = useState(osPath) || "alinux2";
var suggestions = [];
for(let image of customImages)
{
suggestions.push({
value: image.ec2AmiInfo.amiId,
description: `${image.ec2AmiInfo.amiId} (${image.imageId})`
})
}
for(let image of officialImages)
if(image.os === os)
{
suggestions.push({
value: image.amiId,
description: `${image.amiId} (${image.name})`
})
}
const toggleCustomAmi = (event) => {
const value = !customAmiEnabled;
setState(['app', 'wizard', 'customAMI', 'enabled'], value);
if(!value)
clearState(customAmiPath);
}
return (
<>
<div style={{display: "flex", flexDirection: "row", alignItems: "center", justifyContent: "space-between"}}>
<Toggle disabled={editing} checked={customAmiEnabled} onChange={toggleCustomAmi}>Use Custom AMI?</Toggle>
<HelpTooltip>Custom AMI's provide a way to customize the cluster. See the <a rel="noreferrer" target="_blank" href='https://docs.aws.amazon.com/parallelcluster/latest/ug/pcluster.build-image-v3.html'>Image section</a> of the documentation for more information.</HelpTooltip>
</div>
{customAmiEnabled &&
<FormField label="Custom AMI ID"
errorText={error}>
<Autosuggest
onChange={({ detail }) => {setState(customAmiPath, detail.value); clusterValidate()}}
value={customAmi || ""}
enteredTextLabel={value => {setState(customAmiPath, value); clusterValidate()}}
ariaLabel="Custom AMI Selector"
placeholder="AMI ID"
empty="No matches found"
options={suggestions}
/>
</FormField>
}
</>
)
}