Description: This template deploys a minimal stack for testing EFS

Resources:
  VPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.192.0.0/16
      EnableDnsSupport: true
      EnableDnsHostnames: true

  Subnet:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref VPC
      AvailabilityZone: !Select [0, !GetAZs '']
      CidrBlock: 10.192.21.0/24
      MapPublicIpOnLaunch: false

  FileSystem:
    Type: AWS::EFS::FileSystem
    Properties:
      PerformanceMode: generalPurpose
      FileSystemTags:
        - Key: Name
          Value: ServerlessFrameworkTestsVolume

  MountTarget:
    Type: AWS::EFS::MountTarget
    Properties:
      FileSystemId: !Ref FileSystem
      SubnetId: !Ref Subnet
      SecurityGroups:
        - !GetAtt VPC.DefaultSecurityGroup

  AccessPointResource:
    Type: AWS::EFS::AccessPoint
    Properties:
      FileSystemId: !Ref FileSystem
      PosixUser:
        Uid: 1001
        Gid: 1001
      RootDirectory:
        CreationInfo:
          OwnerGid: 1001
          OwnerUid: 1001
          Permissions: 770
        Path: /efs

Outputs:
  Subnet:
    Description: A reference to the subnet
    Value: !Ref Subnet

  SecurityGroup:
    Description: Security group
    Value: !GetAtt VPC.DefaultSecurityGroup

  AccessPointARN:
    Description: Access Point ARN
    Value: !GetAtt AccessPointResource.Arn
