Using environment variable for a cloudformation resource

Hello,

I would like to deploy a S3 bucket with custom rules in it to customise CORS. For the moment the name of the bucket is static and in the cloudformation resources I hardcode the normalised name.

See my serverless.yml below :

service: deepcloud

provider:
  name: aws
  environment:
    DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
  tags:
    project: b12
  runtime: python3.7
  region: eu-central-1
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "s3:*"
      Resource: "arn:aws:s3:::b12-slsupload/*"
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
      Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
  

functions:
  image:
    handler: handler.get_upload_form
    events:
      - http:
          path: upload_form
          method: get
          cors: true
  handleUpload:
    handler: handler.on_upload
    timeout: 900 # Run for 15 minutes max (it's the limit defined by AWS)
    events:
      - s3:
          bucket: b12-slsupload
          event: s3:ObjectCreated:*
  queryProcessingStatus:
    handler: handler.query_processing_status
    events:
      - http:
          path: status/{id}
          method: get
          cors: true

# you can add CloudFormation resource templates here
resources:
  Resources:
    S3BucketB12slsupload:
      Type: AWS::S3::Bucket
      Properties:
        Tags:
        - Key: project
          Value: b12
        BucketName: b12-slsupload
        AccessControl: PublicRead
        CorsConfiguration:
          CorsRules:
          - AllowedMethods:
            - GET
            - PUT
            - POST
            - HEAD
            AllowedOrigins:
            - "*"
            AllowedHeaders:
            - "*"
    HandleUploadLambdaPermissionB12slsuploadS3:
      Type: "AWS::Lambda::Permission"
      Properties:
        FunctionName:
          "Fn::GetAtt":
            - HandleUploadLambdaFunction
            - Arn
        Principal: "s3.amazonaws.com"
        Action: "lambda:InvokeFunction"
        SourceAccount:
          Ref: AWS::AccountId
        SourceArn: "arn:aws:s3:::b12-slsupload"
    ResultDynamoDbTable:
      Type: 'AWS::DynamoDB::Table'
      Properties:
        AttributeDefinitions:
          -
            AttributeName: id
            AttributeType: S
        KeySchema:
          -
            AttributeName: id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
        TableName: ${self:provider.environment.DYNAMODB_TABLE}

plugins:
  - serverless-python-requirements

custom:
  pythonRequirements:
    dockerizePip: non-linux

I would like to have an environment variable for the b12-slsupload name but the S3BucketB12slsupload needs to be adapted also. Does everyone knows if there is a trick for this ?

Thanks !