AWSTemplateFormatVersion: '2010-09-09'
Description: Secrets and environment variables for a GenericSuite aplication.

Parameters:
  AppName:
    Description: Application name
    Type: String
  AppStage:
    Description: Application stage
    Type: String
  KmsKeyAlias:
    Description: KMS Key alias
    Type: String
    Default: genericsuite-key
  EncryptedSecretName:
    Description: Name for the encrypted secret.
    Type: String
  EncryptedSecretDescription:
    Description: Description for the encrypted secret.
    Type: String
  EncryptedSecretSecretString:
    Description: SecretString for the encrypted secret.
    Type: String
  UnEncryptedSecretName:
    Description: Name for the unencrypted envvars.
    Type: String
  UnEncryptedSecretDescription:
    Description: Description for the unencrypted envvars.
    Type: String
  UnEncryptedSecretSecretString:
    Description: SecretString for the unencrypted envvars.
    Type: String


Resources:
  GsEncryptedSecret:
    Type: "AWS::SecretsManager::Secret"
    Properties: 
      # Name: "GsEncryptedSecretName_placeholder"
      Name: !Sub "${EncryptedSecretName}"
      # Description: "GsEncryptedSecretDescription_placeholder"
      Description: !Sub "${EncryptedSecretDescription}"
      # SecretString: '{GsEncryptedSecretSecretString_placeholder}'
      SecretString: !Sub "${EncryptedSecretSecretString}"
      KmsKeyId: !Sub "arn:aws:kms:${AWS::Region}:${AWS::AccountId}:alias/${KmsKeyAlias}"
      Tags:
        - Key: App
          Value: !Ref AppName
        - Key: Stage
          Value: !Ref AppStage

  GsUnEncryptedSecret:
    Type: "AWS::SecretsManager::Secret"
    Properties: 
      # Name: "GsUnEncryptedSecretName_placeholder"
      Name: !Sub "${UnEncryptedSecretName}"
      # Description: "GsUnEncryptedSecretDescription_placeholder"
      Description: !Sub "${UnEncryptedSecretDescription}"
      # SecretString: '{GsUnEncryptedSecretSecretString_placeholder}'
      SecretString: !Sub "${UnEncryptedSecretSecretString}"
      Tags:
        - Key: App
          Value: !Ref AppName
        - Key: Stage
          Value: !Ref AppStage
