Skip to content

Commit

Permalink
add: create ack-efs-filesystem (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroniscode authored Sep 7, 2024
1 parent e4e69e6 commit 2c69a5d
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/create/ack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -36,6 +37,7 @@ func init() {
ec2.NewSecurityGroupResource,
ec2.NewSubnetResource,
ec2.NewVpcResource,
efs.NewFileSystemResource,
ecr.NewResource,
iam.NewRoleResource,
eks.NewFargateProfileResource,
Expand Down
68 changes: 68 additions & 0 deletions pkg/resource/ack/efs/filesystem.go
Original file line number Diff line number Diff line change
@@ -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 }}
`

0 comments on commit 2c69a5d

Please sign in to comment.