-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating Python examples to 0.36.1 (#64)
* WIP: Updating Python examples to 0.36.1 * Adding some ECS examples * Adding more ECS examples * Adding final ECS examples
- Loading branch information
Showing
14 changed files
with
128 additions
and
101 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ __pycache__ | |
*~ | ||
.cdk.staging | ||
cdk.out | ||
.vscode | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,38 @@ | ||
from aws_cdk import cdk | ||
from aws_cdk import ( | ||
aws_autoscaling as autoscaling, | ||
aws_ec2 as ec2, | ||
aws_elasticloadbalancing as elb, | ||
core | ||
) | ||
|
||
|
||
class LoadBalancerStack(cdk.Stack): | ||
def __init__(self, app: cdk.App, id: str, **kwargs) -> None: | ||
class LoadBalancerStack(core.Stack): | ||
def __init__(self, app: core.App, id: str, **kwargs) -> None: | ||
super().__init__(app, id, **kwargs) | ||
|
||
vpc = ec2.Vpc(self, "VPC") | ||
|
||
asg = autoscaling.AutoScalingGroup( | ||
self, | ||
"ASG", | ||
self, "ASG", | ||
vpc=vpc, | ||
instance_type=ec2.InstanceTypePair( | ||
ec2.InstanceClass.Burstable2, ec2.InstanceSize.Micro | ||
instance_type=ec2.InstanceType.of( | ||
ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO | ||
), | ||
machine_image=ec2.AmazonLinuxImage(), | ||
) | ||
|
||
lb = elb.LoadBalancer( | ||
self, "LB", vpc=vpc, internet_facing=True, health_check={"port": 80} | ||
self, "LB", | ||
vpc=vpc, | ||
internet_facing=True, | ||
health_check={"port": 80} | ||
) | ||
lb.add_target(asg) | ||
|
||
listener = lb.add_listener(external_port=80) | ||
listener.connections.allow_default_port_from_any_ipv4("Open to the world") | ||
|
||
|
||
app = cdk.App() | ||
app = core.App() | ||
LoadBalancerStack(app, "LoadBalancerStack") | ||
app.run() | ||
app.synth() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
from aws_cdk import cdk | ||
from aws_cdk import core | ||
|
||
from my_custom_resource import MyCustomResource | ||
|
||
|
||
# A Stack that sets up MyCustomResource and shows how to get an attribute from it. | ||
class MyStack(cdk.Stack): | ||
def __init__(self, scope: cdk.App, id: str, **kwargs) -> None: | ||
# A Stack that sets up MyCustomResource and shows how to get an | ||
# attribute from it. | ||
|
||
class MyStack(core.Stack): | ||
def __init__(self, scope: core.App, id: str, **kwargs) -> None: | ||
super().__init__(scope, id, **kwargs) | ||
|
||
resource = MyCustomResource( | ||
self, "DemoResource", message="CustomResource says hello" | ||
self, "DemoResource", | ||
message="CustomResource says hello", | ||
) | ||
|
||
# Publish the custom resource output | ||
cdk.CfnOutput( | ||
self, | ||
"ResponseMessage", | ||
core.CfnOutput( | ||
self, "ResponseMessage", | ||
description="The message that came back from the Custom Resource", | ||
value=resource.response, | ||
) | ||
|
||
|
||
app = cdk.App() | ||
app = core.App() | ||
MyStack(app, "CustomResourceDemoStack") | ||
app.run() | ||
app.synth() |
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
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
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
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
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
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
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
Oops, something went wrong.