Comments (3)
Hi Josh,
Have you tried something like this:
...
Resource("WebSecurityGroup") {
Type "AWS::EC2::SecurityGroup"
Property "GroupDescription", "Security policies for web servers"
Property "VpcId", "vpc-b543o123"
}
Resource("WebSecurityGroupIngress") {
Type "AWS::EC2::SecurityGroupIngress"
Property "GroupId", Ref("WebSecurityGroup")
Property "IpProtocol", "tcp"
Property "FromPort", 8080
Property "ToPort", 8080
Property "SourceSecurityGroupId", Ref("WebLBSecurityGroup")
}
Resource("WebSecurityGroupIngress8080") {
Type "AWS::EC2::SecurityGroupIngress"
Property "GroupId", Ref("WebSecurityGroup")
Property "IpProtocol", "tcp"
Property "FromPort", 8080
Property "ToPort", 8080
Property "SourceSecurityGroupId", Ref("WebSecurityGroup")
}
Resource("WebSecurityGroupEgress8080") {
Type "AWS::EC2::SecurityGroupEgress"
Property "GroupId", Ref("WebSecurityGroup")
Property "IpProtocol", "tcp"
Property "FromPort", 8080
Property "ToPort", 8080
Property "DestinationSecurityGroupId", Ref("WebSecurityGroup")
}
...
it produced this for me:
...
"WebSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"VpcId" : "vpc-b543o123",
"GroupDescription" : "Security policies for web servers"
}
},
"WebSecurityGroupIngress" : {
"Type" : "AWS::EC2::SecurityGroupIngress",
"Properties" : {
"ToPort" : 8080,
"GroupId" : {
"Ref" : "WebSecurityGroup"
},
"FromPort" : 8080,
"SourceSecurityGroupId" : {
"Ref" : "WebLBSecurityGroup"
},
"IpProtocol" : "tcp"
}
},
"WebSecurityGroupIngress8080" : {
"Type" : "AWS::EC2::SecurityGroupIngress",
"Properties" : {
"ToPort" : 8080,
"GroupId" : {
"Ref" : "WebSecurityGroup"
},
"FromPort" : 8080,
"SourceSecurityGroupId" : {
"Ref" : "WebSecurityGroup"
},
"IpProtocol" : "tcp"
}
},
"WebSecurityGroupEgress8080" : {
"Type" : "AWS::EC2::SecurityGroupEgress",
"Properties" : {
"DestinationSecurityGroupId" : {
"Ref" : "WebSecurityGroup"
},
"ToPort" : 8080,
"GroupId" : {
"Ref" : "WebSecurityGroup"
},
"FromPort" : 8080,
"IpProtocol" : "tcp"
}
},
...
from cfndsl.
@kenong, while the code you show gives the correct output, it avoids all of the type checking mechanisms that cfndsl has to offer. An equivalent snippet that should produce the same results is
EC2_SecurityGroup(:WebSecurityGroup) {
GroupDescription "Security policies for web servers"
VpcId "vpc-b543o123"
}
EC2_SecurityGroupIngress(:WebSecurityGroupIngress) {
GroupId Ref(:WebSecurityGroup)
IpProtocol "tcp"
FromPort 8080
ToPort 8080
SourceSecurityGroupId Ref(:WebSecurityGroup)
}
EC2_SecurityGroupIngress(:WebSecurityGroupIngress8080) {
GroupId Ref(:WebSecurityGroup)
IpProtocol "tcp"
FromPort 8080
ToPort 8080
SourceSecurityGroupId Ref(:WebSecurityGroup)
}
EC2_SecurityGroupEgress(:WebSecurityGroupEgress8080) {
GroupId Ref(:WebSecurityGroup)
IpProtocol "tcp"
FromPort 8080
ToPort 8080
DestinationSecurityGroupId Ref(:WebSecurityGroup)
}
However, it turns out there are some typos in aws_types.yaml in the source code that cause this to not work. Expect a pull request and fix soon.
from cfndsl.
I think that this issue is fixed.
from cfndsl.
Related Issues (20)
- undefined method `EC2_LaunchTemplate' for #<CfnDsl::CloudFormationTemplate:...> (NoMethodError) HOT 1
- gitter.im link is broken (gives 404 not found) HOT 2
- Where should we define custom helper methods? HOT 1
- Possible regressions 0.17.5 -> 1.0.0 HOT 8
- Resources ["Foo"] refer to unknown Reference AWS::Partition HOT 4
- Typo in README examples
- CloudFrontOriginAccessIdentity is an undefined method HOT 4
- Issue with DSL generation from cli arguments HOT 1
- unknown type AWSResourceGroupsGroupJson HOT 1
- Shorthand method of accessing resource attributes via FnSub fails reference checks HOT 1
- Outdated assertion in Readme HOT 1
- SecurityGroupIngress is always an array - 1.1.1 HOT 2
- Task: Generate types from CloudFormation resource registry schemas
- Freeze specifications version HOT 2
- Allow ruby versions until eol
- Missing Support for the TimeZone property of AWS::AutoScaling::ScheduledAction HOT 1
- List ItemType in the specification file breaking template generation with spec version 69.0.0 HOT 1
- AWS::CloudFormation::Interface HOT 4
- Missing AWS::ElasticLoadBalancingV2::LoadBalancer SubnetMapping HOT 2
- Undefined method `Name' for `CfnDsl::AWS::Types::AWS_SSM_Association` HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cfndsl.