Skip to content

Instantly share code, notes, and snippets.

@jsierles

jsierles/pl.js Secret

Created November 7, 2021 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsierles/a2dbf4d4f26f63eb7ae1c3c74bb0b050 to your computer and use it in GitHub Desktop.
Save jsierles/a2dbf4d4f26f63eb7ae1c3c74bb0b050 to your computer and use it in GitHub Desktop.
var pulumi = require("@pulumi/pulumi")
var awsx = require("@pulumi/awsx")
var aws = require("@pulumi/aws")
let config = new pulumi.Config()
const buildEnvironment = async () => {
const stack = pulumi.getStack()
const vpc = new awsx.ec2.Vpc(`pulumi-${stack}`, {
cidrBlock: "10.0.0.0/16",
numberOfNatGateways: 1,
tags: {
"Name": `pulumi-${stack}`
},
})
const appName = `pl-web-${stack}`
const application = new aws.elasticbeanstalk.Application(appName, {
name: appName
})
const solutionStack = pulumi.output(aws.elasticbeanstalk.getSolutionStack({
mostRecent: true,
nameRegex: "64bit Amazon Linux 2 v3.3.7(.*)PHP 8.0",
}));
const publicSubnets = await vpc.getSubnets('public')
const privateSubnets = await vpc.getSubnets('private')
let envVars = config.requireObject("eb_env_vars")
envVars["APP_ENV"] = stack
let devSettings = [
{
name: "VPCId",
namespace: "aws:ec2:vpc",
value: vpc.id,
},
{
name: "Subnets",
namespace: "aws:ec2:vpc",
value: pulumi.interpolate(`${privateSubnets[0].id},${privateSubnets[1].id}`)
},
{
name: "ELBSubnets",
namespace: "aws:ec2:vpc",
value: pulumi.interpolate(`${publicSubnets[0].id},${publicSubnets[1].id}`)
},
{
name: "IamInstanceProfile",
namespace: "aws:autoscaling:launchconfiguration",
value: "aws-elasticbeanstalk-ec2-role",
},
{
name: "ServiceRole",
namespace: "aws:elasticbeanstalk:environment",
value: "arn:aws:iam::871235875628:role/aws-elasticbeanstalk-service-role"
},
{
name: "EC2KeyName",
namespace: "aws:autoscaling:launchconfiguration",
value: keypair.id
},
{
name: "InstanceTypes",
namespace: "aws:ec2:instances",
value: "t3a.large,t3a.medium"
},
{
namespace: "aws:elasticbeanstalk:container:php:phpini",
name: "memory_limit",
value: "4096M"
},
{
namespace: "aws:elasticbeanstalk:container:php:phpini",
name: "document_root",
value: "/public"
},
{
namespace: "aws:elasticbeanstalk:container:php:phpini",
name: "display_errors",
value: "On"
},
{
namespace: "aws:elasticbeanstalk:container:php:phpini",
name: "max_execution_time",
value: "360"
},
{
namespace: "aws:elasticbeanstalk:container:php:phpini",
name: "zlib.output_compression",
value: "On"
},
{
namespace: "aws:autoscaling:asg",
name: "MinSize",
value: "4"
},
{
namespace: "aws:autoscaling:asg",
name: "MaxSize",
value: "6"
},
{
namespace: "aws:elasticbeanstalk:environment",
name: "LoadBalancerType",
value: "application"
},
{
namespace: "aws:elasticbeanstalk:managedactions:platformupdate",
name: "UpdateLevel",
value: "minor"
},
{
namespace: "aws:elasticbeanstalk:managedactions",
name: "ManagedActionsEnabled",
value: "true"
},
{
namespace: "aws:elasticbeanstalk:managedactions",
name: "PreferredStartTime",
value: "Sat:03:00"
},
{
namespace: "aws:elb:loadbalancer",
"name": "LoadBalancerHTTPSPort",
value: "443"
},
{
namespace: "aws:elb:loadbalancer",
"name": "SSLCertificateId",
value: "arn:aws:acm:eu-west-1:871235875628:certificate/0f081d79-f5c5-446a-a1fb-5c91d7177819"
}
]
for (k of Object.keys(envVars)) {
const entry = {
name: k,
value: envVars[k],
namespace: "aws:elasticbeanstalk:application:environment"
}
devSettings.push(entry)
}
const environment = new aws.elasticbeanstalk.Environment(appName, {
name: appName,
application: application.name,
solutionStackName: solutionStack.name,
settings: devSettings,
})
const exports = {
endpointUrl: environment.endpointUrl,
//key: key.keyId
}
}
exports = buildEnvironment()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment