Skip to content

Commit 4a01ae9

Browse files
committed
Feature change cycloidio#368
1 parent 4129490 commit 4a01ae9

10 files changed

+482
-392
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## [Unreleased]
22

3+
## Added
4+
- Added new AWS resources: `aws_ec2_managed_prefix_list`
5+
([Issue #368](https://github.com/cycloidio/terracognita/issues/368))
6+
37
## Added
48

59
- Azurerm now can use the `--tags` filter

aws/cmd/functions.go

+10
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,16 @@ var (
477477
// Returned values are commented in the interface doc comment block.
478478
`,
479479
},
480+
Function{
481+
FnName: "GetManagedPrefixLists",
482+
Entity: "ManagedPrefixList",
483+
Prefix: "Describe",
484+
Service: "ec2",
485+
Documentation: `
486+
// GetManagedPrefixLists returns the ec2 Managed Prefix Lists on the given input
487+
// Returned values are commented in the interface doc comment block.
488+
`,
489+
},
480490
Function{
481491
FnName: "GetTransitGateways",
482492
Entity: "TransitGateways",

aws/reader/reader.go

+35
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ type Reader interface {
229229
// Returned values are commented in the interface doc comment block.
230230
GetRouteTables(ctx context.Context, input *ec2.DescribeRouteTablesInput) ([]*ec2.RouteTable, error)
231231

232+
// GetManagedPrefixLists returns the ec2 Managed Prefix Lists on the given input
233+
// Returned values are commented in the interface doc comment block.
234+
GetManagedPrefixLists(ctx context.Context, input *ec2.DescribeManagedPrefixListsInput) ([]*ec2.ManagedPrefixList, error)
235+
232236
// GetTransitGateways returns the ec2 Transit Gateways on the given input
233237
// Returned values are commented in the interface doc comment block.
234238
GetTransitGateways(ctx context.Context, input *ec2.DescribeTransitGatewaysInput) ([]*ec2.TransitGateway, error)
@@ -1800,6 +1804,37 @@ func (c *connector) GetRouteTables(ctx context.Context, input *ec2.DescribeRoute
18001804
return opt, nil
18011805
}
18021806

1807+
func (c *connector) GetManagedPrefixLists(ctx context.Context, input *ec2.DescribeManagedPrefixListsInput) ([]*ec2.ManagedPrefixList, error) {
1808+
if c.svc.ec2 == nil {
1809+
c.svc.ec2 = ec2.New(c.svc.session)
1810+
}
1811+
1812+
opt := make([]*ec2.ManagedPrefixList, 0)
1813+
1814+
hasNextToken := true
1815+
for hasNextToken {
1816+
o, err := c.svc.ec2.DescribeManagedPrefixListsWithContext(ctx, input)
1817+
if err != nil {
1818+
return nil, err
1819+
}
1820+
if o.PrefixLists == nil {
1821+
hasNextToken = false
1822+
continue
1823+
}
1824+
1825+
if input == nil {
1826+
input = &ec2.DescribeManagedPrefixListsInput{}
1827+
}
1828+
input.NextToken = o.NextToken
1829+
hasNextToken = o.NextToken != nil
1830+
1831+
opt = append(opt, o.PrefixLists...)
1832+
1833+
}
1834+
1835+
return opt, nil
1836+
}
1837+
18031838
func (c *connector) GetTransitGateways(ctx context.Context, input *ec2.DescribeTransitGatewaysInput) ([]*ec2.TransitGateway, error) {
18041839
if c.svc.ec2 == nil {
18051840
c.svc.ec2 = ec2.New(c.svc.session)

aws/resources.go

+23
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const (
8484
ECSCluster
8585
ECSService
8686
ECSTaskDefinition
87+
EC2ManagedPrefixList
8788
EC2TransitGateway
8889
EC2TransitGatewayVPCAttachment
8990
EC2TransitGatewayRouteTable
@@ -225,6 +226,7 @@ var (
225226
ECSCluster: cacheECSClusters,
226227
ECSService: ecsServices,
227228
ECSTaskDefinition: ecsTaskDefinitions,
229+
EC2ManagedPrefixList: ec2ManagedPrefixList,
228230
EC2TransitGateway: ec2TransitGateways,
229231
EC2TransitGatewayVPCAttachment: ec2TransitGatewayVPCAttachment,
230232
EC2TransitGatewayRouteTable: cacheTransitGatewayRouteTables,
@@ -1280,6 +1282,27 @@ func ecsTaskDefinitions(ctx context.Context, a *aws, resourceType string, filter
12801282
return resources, nil
12811283
}
12821284

1285+
func ec2ManagedPrefixList(ctx context.Context, a *aws, resourceType string, filters *filter.Filter) ([]provider.Resource, error) {
1286+
managedPrefixList, err := a.awsr.GetManagedPrefixLists(ctx, nil)
1287+
if err != nil {
1288+
return nil, err
1289+
}
1290+
1291+
resources := make([]provider.Resource, 0)
1292+
1293+
for _, i := range managedPrefixList {
1294+
1295+
r, err := initializeResource(a, *i.PrefixListId, resourceType)
1296+
if err != nil {
1297+
return nil, err
1298+
}
1299+
1300+
resources = append(resources, r)
1301+
}
1302+
1303+
return resources, nil
1304+
}
1305+
12831306
func ec2TransitGateways(ctx context.Context, a *aws, resourceType string, filters *filter.Filter) ([]provider.Resource, error) {
12841307
transitGateways, err := a.awsr.GetTransitGateways(ctx, nil)
12851308
if err != nil {

aws/resourcetype_enumer.go

+386-382
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

azurerm/resourcetype_enumer.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

+6-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require (
3131
github.com/stretchr/testify v1.7.0
3232
github.com/vmware/govmomi v0.28.0
3333
github.com/zclconf/go-cty v1.10.0
34-
golang.org/x/text v0.7.0
34+
golang.org/x/text v0.8.0
3535
google.golang.org/api v0.61.0
3636
google.golang.org/grpc v1.45.0
3737
gopkg.in/yaml.v2 v2.4.0
@@ -81,6 +81,7 @@ require (
8181
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
8282
github.com/davecgh/go-spew v1.1.1 // indirect
8383
github.com/dimchansky/utfbom v1.1.1 // indirect
84+
github.com/dmarkham/enumer v1.5.8 // indirect
8485
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021 // indirect
8586
github.com/envoyproxy/protoc-gen-validate v0.1.0 // indirect
8687
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
@@ -164,10 +165,11 @@ require (
164165
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
165166
go.opencensus.io v0.23.0 // indirect
166167
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
167-
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
168-
golang.org/x/net v0.7.0 // indirect
168+
golang.org/x/mod v0.9.0 // indirect
169+
golang.org/x/net v0.8.0 // indirect
169170
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
170-
golang.org/x/sys v0.5.0 // indirect
171+
golang.org/x/sys v0.6.0 // indirect
172+
golang.org/x/tools v0.7.0 // indirect
171173
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
172174
google.golang.org/appengine v1.6.7 // indirect
173175
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1 // indirect

go.sum

+12
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8
321321
github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=
322322
github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U=
323323
github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE=
324+
github.com/dmarkham/enumer v1.5.8 h1:fIF11F9l5jyD++YYvxcSH5WgHfeaSGPaN/T4kOQ4qEM=
325+
github.com/dmarkham/enumer v1.5.8/go.mod h1:d10o8R3t/gROm2p3BXqTkMt2+HMuxEmWCXzorAruYak=
324326
github.com/dnaeon/go-vcr v1.0.1 h1:r8L/HqC0Hje5AXMu1ooW8oyQyOFv4GxqpL0nRP7SLLY=
325327
github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E=
326328
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
@@ -1274,6 +1276,8 @@ golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
12741276
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
12751277
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
12761278
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
1279+
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
1280+
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
12771281
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
12781282
golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
12791283
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -1342,6 +1346,8 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su
13421346
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
13431347
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
13441348
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
1349+
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
1350+
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
13451351
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
13461352
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
13471353
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1466,6 +1472,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
14661472
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
14671473
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
14681474
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1475+
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
1476+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
14691477
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
14701478
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
14711479
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -1483,6 +1491,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
14831491
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
14841492
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
14851493
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
1494+
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
1495+
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
14861496
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
14871497
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
14881498
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -1596,6 +1606,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
15961606
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
15971607
golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
15981608
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
1609+
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
1610+
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
15991611
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
16001612
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
16011613
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

google/resourcetype_enumer.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vsphere/resourcetype_enumer.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)