I am building a automated system to configure lightsail wordpress instances with static ip addresses using the lambda function. I have two approaches either of these will work for me.
1- Is it possible to configure the administrator user credentials while configuration?
2- How to get the default application password while configuration in lambda automatically.|
This is the code I am using for lightsail wordpress instance configuration.
`module.exports.createLightsailInstance = async (event) => {
try {
const instanceNames = JSON.parse(event?.body).instanceNames;
const instanceCreationPromises = instanceNames.map(async (instanceName) => {
// Create a Lightsail instance
const createInstanceParams = {
instanceNames: [instanceName],
blueprintId: 'wordpress',
bundleId: 'nano_3_0',
availabilityZone: 'ap-northeast-1a',
tags: [
{
key: 'Name',
value: instanceName
}
],
};
const createInstanceResponse = await lightsail.createInstances(createInstanceParams).promise();
return createInstanceResponse;
});
await Promise.all(instanceCreationPromises);
return {
statusCode: 200,
body: JSON.stringify({
message: 'Lightsail instances are successfully created. You can run them in few minutes.',
data: createInstanceResponse,
})
};
} catch (error) {
return {
statusCode: 500,
body: JSON.stringify({
message: 'Failed to create Lightsail instances.'
})
};
}
};
`
I have tried to SSM but it is not working for me.
Nauman Asif is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.