From 2c69a5da702126c19f147c1c7ca63fee5a205d84 Mon Sep 17 00:00:00 2001 From: Aaron Miller <1521726+aaroniscode@users.noreply.github.com> Date: Fri, 6 Sep 2024 18:31:00 -0700 Subject: [PATCH] add: `create ack-efs-filesystem` (#243) --- cmd/create/ack.go | 2 + pkg/resource/ack/efs/filesystem.go | 68 ++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 pkg/resource/ack/efs/filesystem.go diff --git a/cmd/create/ack.go b/cmd/create/ack.go index 155cc3e..ff6d2d5 100644 --- a/cmd/create/ack.go +++ b/cmd/create/ack.go @@ -5,6 +5,7 @@ import ( "github.com/awslabs/eksdemo/pkg/resource/ack/amp" "github.com/awslabs/eksdemo/pkg/resource/ack/ec2" "github.com/awslabs/eksdemo/pkg/resource/ack/ecr" + "github.com/awslabs/eksdemo/pkg/resource/ack/efs" "github.com/awslabs/eksdemo/pkg/resource/ack/eks" "github.com/awslabs/eksdemo/pkg/resource/ack/iam" "github.com/awslabs/eksdemo/pkg/resource/ack/s3" @@ -36,6 +37,7 @@ func init() { ec2.NewSecurityGroupResource, ec2.NewSubnetResource, ec2.NewVpcResource, + efs.NewFileSystemResource, ecr.NewResource, iam.NewRoleResource, eks.NewFargateProfileResource, diff --git a/pkg/resource/ack/efs/filesystem.go b/pkg/resource/ack/efs/filesystem.go new file mode 100644 index 0000000..56ad26e --- /dev/null +++ b/pkg/resource/ack/efs/filesystem.go @@ -0,0 +1,68 @@ +package efs + +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 FileSystemOptions struct { + resource.CommonOptions + ThroughputMode string +} + +func NewFileSystemResource() *resource.Resource { + options := &FileSystemOptions{ + CommonOptions: resource.CommonOptions{ + Namespace: "default", + NamespaceFlag: true, + }, + ThroughputMode: "bursting", + } + + return &resource.Resource{ + Command: cmd.Command{ + Name: "efs-filesystem", + Description: "EFS File System", + Aliases: []string{"efs"}, + CreateArgs: []string{"NAME"}, + }, + + CreateFlags: cmd.Flags{ + &cmd.StringFlag{ + CommandFlag: cmd.CommandFlag{ + Name: "throughput-mode", + Description: "specifies the throughput mode for the file system", + }, + Option: &options.ThroughputMode, + Choices: []string{"elastic", "provisioned", "bursting"}, + }, + }, + + Manager: &manifest.ResourceManager{ + Template: &template.TextTemplate{ + Template: fileSystemYamlTemplate, + }, + }, + + Options: options, + } +} + +const fileSystemYamlTemplate = `--- +apiVersion: efs.services.k8s.aws/v1alpha1 +kind: FileSystem +metadata: + name: {{ .Name }} + namespace: {{ .Namespace }} +spec: + encrypted: true + fileSystemProtection: + replicationOverwriteProtection: ENABLED + performanceMode: generalPurpose + throughputMode: {{ .ThroughputMode }} + tags: + - key: Name + value: {{ .Name }} +`