-
-
Save clstokes/75162674b24a2f35c4c35e52edac8429 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import pulumi | |
from pulumi_aws import elasticbeanstalk | |
project_name = pulumi.get_project() | |
stack_name = pulumi.get_stack() | |
resource_name = '{}-{}'.format(project_name, stack_name) | |
# Beanstalk resources are auto-named, so don't provide a 'Name' tag to them | |
tags_without_name = { | |
'project': project_name, | |
'stack': stack_name, | |
} | |
# Provide a 'Name' tag for all other resources | |
tags = {**tags_without_name, 'Name': resource_name} | |
# | |
# Elastic Beanstalk resources | |
# | |
app = elasticbeanstalk.Application(resource_name, | |
tags=tags_without_name, | |
) | |
version = elasticbeanstalk.ApplicationVersion(resource_name, | |
application=app.name, | |
bucket='elasticbeanstalk-samples-us-west-2', #TODO: parameterize region | |
key='docker-sample-v3.zip', | |
tags=tags_without_name, | |
) | |
wait_time = '35m' | |
env = elasticbeanstalk.Environment(resource_name, | |
application=app.name, | |
version=version.name, | |
solution_stack_name='64bit Amazon Linux 2018.03 v2.14.3 running Docker 18.09.9-ce', | |
tags=tags_without_name, | |
wait_for_ready_timeout=wait_time, | |
opts=pulumi.ResourceOptions(custom_timeouts={'create': wait_time},), | |
settings=[ | |
{'namespace': 'aws:ec2:vpc', 'name': 'ELBScheme', 'value': 'public', }, | |
{'namespace': 'aws:autoscaling:asg', 'name': 'MinSize', 'value': '2', 'resource': 'AWSEBAutoScalingGroup', }, | |
{'namespace': 'aws:autoscaling:asg', 'name': 'MaxSize', 'value': '2', 'resource': 'AWSEBAutoScalingGroup', }, | |
{'namespace': 'aws:autoscaling:launchconfiguration', 'name': 'InstanceType', 'value': 't3.medium', 'resource': '', }, | |
{'namespace': 'aws:autoscaling:launchconfiguration', 'name': 'IamInstanceProfile', 'value': 'aws-elasticbeanstalk-ec2-role', 'resource': 'AWSEBAutoScalingLaunchConfiguration', }, | |
{'namespace': 'aws:elasticbeanstalk:environment', 'name': 'ServiceRole', 'value': 'arn:aws:iam::052848974346:role/aws-elasticbeanstalk-service-role', 'resource': '', }, | |
{'namespace': 'aws:elasticbeanstalk:environment:proxy', 'name': 'ProxyServer', 'value': 'nginx', 'resource': '', }, | |
], | |
) | |
pulumi.export('applicationName', app.name) | |
pulumi.export('environmentName', env.name) | |
pulumi.export('url', env.endpoint_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pulumi>=1.0.0 | |
pulumi-aws>=1.0.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment