Cannot update S3 bucket

Hi all, hope you are well, I inherithed a project with the following serverless.yaml

# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
#    docs.serverless.com
#
# Happy Coding!
frameworkVersion: '3'

service: xphub-sitemap
# app and org for use with dashboard.serverless.com
#app: your-app-name
#org: your-org-name

package:
  individually: true

plugins:
  - serverless-webpack

provider:
  name: aws
  runtime: nodejs18.x
  region: eu-central-1
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "s3:GetObject"
        - "s3:PutObject"
        - "s3:ListBucket"
      Resource:
        - arn:aws:s3:::${self:custom.sitemapBucket}/*
  environment:
    NODE_OPTIONS: --openssl-legacy-provider
    NODE_CONFIG: ${ssm:/xphub-sitemap/${opt:stage, self:provider.stage}/config}
    SITEMAP_BUCKET_NAME: ${self:custom.sitemapBucket}

custom:
  stage: ${opt:stage, self:provider.stage}
  sitemapBucket: xphub-sitemap-${self:custom.stage}-${AWS::AccountId}
  shopName: dooitu-b2c-${self:custom.stage}
  webpack:
    webpackConfig: 'webpack.config.js'
    packager: 'yarn'
    includeModules: true

functions:
  sitemap:
    handler: src/lambda/sitemap.handler
    timeout: 900
    memorySize: 4096
    events:
      - schedule:
         rate: cron(0 2 * * ? *)
         enabled: true

resources:
  Resources:
    S3BucketSellout:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: ${self:custom.sitemapBucket}
        PublicAccessBlockConfiguration:
            BlockPublicAcls: false
            BlockPublicPolicy: false
            IgnorePublicAcls: false
            RestrictPublicBuckets: false

I tried to deploy the application but the following error arise

UPDATE_FAILED: S3BucketSellout (AWS::S3::Bucket)
Bad Request (Service: Amazon S3; Status Code: 400; Error Code: 400 Bad Request; Request ID: BB0C1E71K8QGXH56; S3 Extended Request ID: fmWQ6Ewiuyw8kVJim0T9307sVxr2R7/+K8KLxJSyDKsEBrWjX/kdh6J4AR1SEbQ5B4JIgZ02WGE=; Proxy: null)

I want to specify that I am trying to upgrade the serverless framework from version 2 to version 3 because I want to use node18 that is an LTS instead of node14 and node16 that will be deprecated soon.

Any clue of this error ?

aculnaig

For those who are wondering what the error is; this line

sitemapBucket: xphub-sitemap-${self:custom.stage}-${AWS::AccountId}

and in particular ${AWS::AccountId} must be changed to ${aws:accountId}

Cheers

aculnaig