Skip to content

Commit f36a328

Browse files
committed
feat: enable s3 endpoint for VPC and Public Subnet on standard network for AWS
This setup allow us to move things to S3 and reuse them internally without extra cost (no internet access required) Signed-off-by: Adrian Riobo <[email protected]>
1 parent 83fd523 commit f36a328

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

pkg/provider/aws/modules/network/standard/standard.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func DefaultNetworkRequest(name, regionName string) NetworkRequest {
8989
return NetworkRequest{
9090
Name: name,
9191
CIDR: DefaultCIDRNetwork,
92+
Region: regionName,
9293
AvailabilityZones: azs,
9394
PublicSubnetsCIDRs: GeneratePublicSubnetCIDRs(azCount),
9495
PrivateSubnetsCIDRs: GeneratePrivateSubnetCIDRs(azCount),
@@ -166,6 +167,7 @@ func (r NetworkRequest) managePublicSubnets(mCtx *mc.Context, vpc *ec2.Vpc,
166167
VPC: vpc,
167168
InternetGateway: igw,
168169
CIDR: r.PublicSubnetsCIDRs[i],
170+
Region: r.Region,
169171
AvailabilityZone: r.AvailabilityZones[i],
170172
Name: fmt.Sprintf("%s%s%d", namePrefix, r.Name, i),
171173
AddNatGateway: r.checkIfNatGatewayRequired(i),

pkg/provider/aws/services/vpc/subnet/public.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type PublicSubnetRequest struct {
1313
VPC *ec2.Vpc
1414
InternetGateway *ec2.InternetGateway
1515
CIDR string
16+
Region string
1617
AvailabilityZone string
1718
Name string
1819
AddNatGateway bool
@@ -89,6 +90,18 @@ func (r PublicSubnetRequest) Create(ctx *pulumi.Context, mCtx *mc.Context) (*Pub
8990
if err != nil {
9091
return nil, err
9192
}
93+
// Create the S3 VPC endpoint (Gateway type)
94+
_, err = ec2.NewVpcEndpoint(ctx,
95+
fmt.Sprintf("%s-%s", "s3", r.Name),
96+
&ec2.VpcEndpointArgs{
97+
VpcId: r.VPC.ID(),
98+
ServiceName: pulumi.Sprintf("com.amazonaws.%s.s3", r.Region),
99+
VpcEndpointType: pulumi.String("Gateway"),
100+
RouteTableIds: pulumi.StringArray{rt.ID()},
101+
})
102+
if err != nil {
103+
return nil, err
104+
}
92105
return &PublicSubnetResources{
93106
Subnet: sn,
94107
RouteTable: rt,

0 commit comments

Comments
 (0)