File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ func (awsAction *AwsAction) createPrivateEndpoint(pe status.ProjectPrivateEndpoi
2323 if err != nil {
2424 return v1.PrivateEndpoint {}, err
2525 }
26- subnetID , err := session .GetSubnetID ( )
26+ subnetID , err := session .GetOrCreateSubnetIDForVpc ( vpcID )
2727 if err != nil {
2828 return v1.PrivateEndpoint {}, err
2929 }
Original file line number Diff line number Diff line change @@ -98,24 +98,28 @@ func (s sessionAWS) DeleteVPC(vpcID string) error {
9898 return nil
9999}
100100
101- func (s sessionAWS ) GetSubnetID ( ) (string , error ) {
101+ func (s sessionAWS ) GetOrCreateSubnetIDForVpc ( vpcID string ) (string , error ) {
102102 input := & ec2.DescribeSubnetsInput {
103- Filters : []* ec2.Filter {{
104- Name : aws .String ("tag:Name" ),
105- Values : []* string {
106- aws .String (config .TagName ),
103+ Filters : []* ec2.Filter {
104+ {
105+ Name : aws .String ("vpc-id" ),
106+ Values : []* string {
107+ aws .String (vpcID ),
108+ },
107109 },
108- }} ,
110+ },
109111 }
112+
110113 result , err := s .ec2 .DescribeSubnets (input )
111114 if err != nil {
112115 return "" , getError (err )
113116 }
114- if len (result .Subnets ) < 1 {
115- return "" , errors .New ("can not find Subnet" )
117+
118+ if len (result .Subnets ) > 0 {
119+ return * result .Subnets [0 ].SubnetId , nil
116120 }
117- fmt . Println ( result )
118- return * result . Subnets [ 0 ]. SubnetId , nil
121+
122+ return s . CreateSubnet ( vpcID , "10.0.0.0/24" , "pe-aws-test" )
119123}
120124
121125func (s sessionAWS ) CreateSubnet (vpcID , cidr , testID string ) (string , error ) {
You can’t perform that action at this time.
0 commit comments