-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Closed
Description
It would be great do find some examples how to create new security groups with ingress and egress rules. Currently its hard to find some hints how to provide the parameters for addIngressRule of a newly created securitygroup.
Here a short typescript sample that creates a new vpc, a security-group and an ec2-instance. Maybe it is helpul:
const vpc = new ec2.VpcNetwork(this, 'NewVPC');
let mySecurityGroup = new ec2.SecurityGroup(this, 'NewSecurityGroup', {
description: 'Allow ssh access to ec2 instances',
groupName: 'ec2-ssh-access',
vpc: vpc
});
mySecurityGroup.addIngressRule(new ec2.AnyIPv4(), new ec2.TcpPort(22), 'allow ssh access from any ipv4 ip');
new ec2.cloudformation.InstanceResource(this, 'Ec2Instance', {
imageId: ' ami-0f5dbc86dd9cbf7a8',
securityGroupIds: [ mySecurityGroup.securityGroupId],
instanceType: 't2.micro',
tags: [{
key: 'Name',
value: 'my-new-ec2-instance'
}]
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels