-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6386fcd
commit 3262ee6
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package vpc | ||
|
||
import ( | ||
"github.com/awslabs/eksdemo/pkg/cmd" | ||
"github.com/awslabs/eksdemo/pkg/manifest" | ||
"github.com/awslabs/eksdemo/pkg/resource" | ||
"github.com/awslabs/eksdemo/pkg/template" | ||
) | ||
|
||
type Options struct { | ||
resource.CommonOptions | ||
CidrBlock string | ||
} | ||
|
||
func NewResource() *resource.Resource { | ||
options := &Options{ | ||
CommonOptions: resource.CommonOptions{ | ||
Name: "crossplane-vpc", | ||
Namespace: "default", | ||
NamespaceFlag: true, | ||
}, | ||
CidrBlock: "10.0.0.0/16", | ||
} | ||
|
||
flags := cmd.Flags{ | ||
&cmd.StringFlag{ | ||
CommandFlag: cmd.CommandFlag{ | ||
Name: "cidr", | ||
Description: "IPv4 CIDR block for your VPC", | ||
}, | ||
Option: &options.CidrBlock, | ||
}, | ||
} | ||
|
||
return &resource.Resource{ | ||
Command: cmd.Command{ | ||
Name: "vpc", | ||
Description: "Virtual Private Cloud", | ||
CreateArgs: []string{"NAME"}, | ||
}, | ||
|
||
CreateFlags: flags, | ||
|
||
Manager: &manifest.ResourceManager{ | ||
Template: &template.TextTemplate{ | ||
Template: yamlTemplate, | ||
}, | ||
}, | ||
|
||
Options: options, | ||
} | ||
} | ||
|
||
const yamlTemplate = `--- | ||
apiVersion: ec2.aws.upbound.io/v1beta1 | ||
kind: VPC | ||
metadata: | ||
name: {{ .Name }} | ||
namespace: {{ .Namespace }} | ||
spec: | ||
forProvider: | ||
region: {{ .Region }} | ||
cidrBlock: {{ .CidrBlock }} | ||
enableDnsSupport: true | ||
enableDnsHostnames: true | ||
tags: | ||
Name: {{ .Name }} | ||
` |