# Just one function with a deployment preference
Resources:
  MyLambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: ${codeuri}
      Handler: index.handler
      Runtime: python3.11

      AutoPublishAlias: Live

      DeploymentPreference:
        Type: AllAtOnce
        Role:
          Fn::GetAtt: [DeploymentRole, Arn]

  DeploymentRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Action:
          - sts:AssumeRole
          Effect: Allow
          Principal:
            Service:
            - codedeploy.amazonaws.com

      Policies:
      - PolicyName: root
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Resource: '*'
            Action:
            - cloudwatch:DescribeAlarms
            - lambda:UpdateAlias
            - lambda:GetAlias
            - lambda:InvokeFunction
            - s3:Get*
            - sns:Publish
Metadata:
  SamTransformTest: true
