Skip to content

Commit ce74314

Browse files
ppitonakadrianriobo
authored andcommitted
feat(aws): tag elastic IPs, load balancer, and VPC endpoints
Most of the resources created by mapt are tagged with user-provided list of tags. Elastic IPs, load balancer, target groups, listeners, VPC endpoints, and their security group were not. Signed-off-by: Pavol Pitonak <ppitonak@redhat.com>
1 parent d70d635 commit ce74314

6 files changed

Lines changed: 17 additions & 1 deletion

File tree

pkg/provider/aws/modules/ec2/compute/compute.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ func (r ComputeRequest) createForwardTargetGRoups(ctx *pulumi.Context, port int)
368368
// Set to 0 for instant deregistration on destroy;
369369
// these are ephemeral machines with no live connections to drain.
370370
DeregistrationDelay: pulumi.Int(0),
371+
Tags: r.MCtx.ResourceTags(),
371372
})
372373
if err != nil {
373374
return nil, err
@@ -384,6 +385,7 @@ func (r ComputeRequest) createForwardTargetGRoups(ctx *pulumi.Context, port int)
384385
TargetGroupArn: tg.Arn,
385386
},
386387
},
388+
Tags: r.MCtx.ResourceTags(),
387389
}); err != nil {
388390
return nil, err
389391
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func (r AirgapNetworkRequest) CreateNetwork(ctx *pulumi.Context, mCtx *mc.Contex
5353
}
5454
// Create VPC endpoints for the public subnet
5555
err = subnet.EndpointsRequest{
56+
MCtx: mCtx,
5657
VPC: result.VPCResources.VPC,
5758
Subnets: []*ec2.Subnet{result.PublicSubnet.Subnet},
5859
RouteTables: []*ec2.RouteTable{result.PublicSubnet.RouteTable},

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,17 @@ func Create(ctx *pulumi.Context, mCtx *mc.Context, args *NetworkArgs) (*NetworkR
7676
}
7777
result.Eip, err = ec2.NewEip(ctx,
7878
resourcesUtil.GetResourceName(args.Prefix, args.ID, "lbeip"),
79-
&ec2.EipArgs{})
79+
&ec2.EipArgs{
80+
Tags: mCtx.ResourceTags(),
81+
})
8082
if err != nil {
8183
return nil, err
8284
}
8385
if args.CreateLoadBalancer {
8486
lba := &loadBalancerArgs{
8587
prefix: &args.Prefix,
8688
id: &args.ID,
89+
mCtx: mCtx,
8790
subnet: result.Subnet,
8891
}
8992
if !args.Airgap {
@@ -139,6 +142,7 @@ func airgapNetworking(ctx *pulumi.Context, mCtx *mc.Context, args *NetworkArgs)
139142

140143
type loadBalancerArgs struct {
141144
prefix, id *string
145+
mCtx *mc.Context
142146
subnet *ec2.Subnet
143147
// If eip != nil it means it is not airgap
144148
eip *ec2.Eip
@@ -150,6 +154,7 @@ func loadBalancer(ctx *pulumi.Context, args *loadBalancerArgs) (*lb.LoadBalancer
150154
lbArgs := &lb.LoadBalancerArgs{
151155
LoadBalancerType: pulumi.String("network"),
152156
EnableDeletionProtection: pulumi.Bool(false),
157+
Tags: args.mCtx.ResourceTags(),
153158
}
154159
snMapping := &lb.LoadBalancerSubnetMappingArgs{
155160
SubnetId: args.subnet.ID()}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ func (r NetworkRequest) CreateNetwork(ctx *pulumi.Context) (*NetworkResources, e
128128
routeTables[i] = snr.RouteTable
129129
}
130130
err = subnet.EndpointsRequest{
131+
MCtx: r.MCtx,
131132
VPC: vpcResult.VPC,
132133
Subnets: subnets,
133134
RouteTables: routeTables,

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import (
55

66
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2"
77
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
8+
mc "github.com/redhat-developer/mapt/pkg/manager/context"
89
)
910

1011
var validEndpoints = map[string]bool{"s3": true, "ecr": true, "ssm": true}
1112

1213
type EndpointsRequest struct {
14+
MCtx *mc.Context
1315
VPC *ec2.Vpc
1416
Subnets []*ec2.Subnet
1517
RouteTables []*ec2.RouteTable
@@ -51,6 +53,7 @@ func (r EndpointsRequest) Create(ctx *pulumi.Context) error {
5153
CidrBlocks: pulumi.StringArray{r.VPC.CidrBlock},
5254
},
5355
},
56+
Tags: r.MCtx.ResourceTags(),
5457
})
5558
if err != nil {
5659
return err
@@ -76,6 +79,7 @@ func (r EndpointsRequest) Create(ctx *pulumi.Context) error {
7679
ServiceName: pulumi.Sprintf("com.amazonaws.%s.s3", r.Region),
7780
VpcEndpointType: pulumi.String("Gateway"),
7881
RouteTableIds: routeTableIds,
82+
Tags: r.MCtx.ResourceTags(),
7983
})
8084
if err != nil {
8185
return err
@@ -89,6 +93,7 @@ func (r EndpointsRequest) Create(ctx *pulumi.Context) error {
8993
VpcEndpointType: pulumi.String("Interface"),
9094
SubnetIds: subnetIds,
9195
SecurityGroupIds: pulumi.StringArray{sg.ID()},
96+
Tags: r.MCtx.ResourceTags(),
9297
})
9398
if err != nil {
9499
return err
@@ -102,6 +107,7 @@ func (r EndpointsRequest) Create(ctx *pulumi.Context) error {
102107
VpcEndpointType: pulumi.String("Interface"),
103108
SubnetIds: subnetIds,
104109
SecurityGroupIds: pulumi.StringArray{sg.ID()},
110+
Tags: r.MCtx.ResourceTags(),
105111
})
106112
if err != nil {
107113
return err

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func (r PublicSubnetRequest) Create(ctx *pulumi.Context, mCtx *mc.Context) (*Pub
4949
fmt.Sprintf("%s-%s", "eip", r.Name),
5050
&ec2.EipArgs{
5151
Domain: pulumi.String("vpc"),
52+
Tags: mCtx.ResourceTags(),
5253
})
5354
if err != nil {
5455
return nil, err

0 commit comments

Comments
 (0)