question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use stage parameters for profile

See original GitHub issue

Are you certain it’s a bug?

  • Yes, it looks like a bug

Is the issue caused by a plugin?

  • It is not a plugin issue

Are you using the latest version?

  • Yes, I’m using the latest version

Is there an existing issue for this?

  • I have searched existing issues, it hasn’t been reported yet

Issue description

Hello ! I was trying to implement the stage parameters feature from the V3 and unfortunately it seems that the provider.profile property cannot use this feature, is it a bug or is it just not supported?

Thanks a lot for your help.

Service configuration (serverless.yml) content

const serverlessConfiguration: AWS & ServerlessContracts = {
  service: `${projectName}-core`, // Keep it short to have role name below 64
  frameworkVersion: '>=3.0.0',
  configValidationMode: 'error',
  plugins: [],
  provider: {
    name: 'aws',
    runtime: 'nodejs14.x',
    architecture: 'arm64',
    region: 'eu-west-1',
    profile: '${param:profile}', // Used to point to the right AWS account
    stage: "${opt:stage, 'dev'}",
    environment: {
      AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
      NODE_OPTIONS: '--enable-source-maps --stack-trace-limit=1000',
    },
    eventBridge: {
      useCloudFormation: true,
    },
    httpApi: {
      payload: '2.0',
      cors: {
        // @ts-ignore we use a configuration per environment so we put it as a serverless variable
        allowedOrigins: '${param:apiGatewayCorsAllowedOrigins}',
        allowedHeaders: ['Content-Type', 'Authorization', 'Origin'],
        allowedMethods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
        allowCredentials: true,
      },
      metrics: true,
    },
  },
  functions,
  package: { individually: true },
  params: {
    dev: {
      profile: 'sls-monorepo-developer',
      apiGatewayCorsAllowedOrigins: ['http://localhost:3000'],
    },
    staging: {
      profile: '',
      apiGatewayCorsAllowedOrigins: ['https://staging.my-domain.com'],
    },
    production: {
      profile: '',
      apiGatewayCorsAllowedOrigins: ['https://www.my-domain.com'],
    },
  },
  custom: {
    projectName,
    esbuild: sharedEsbuildConfig,
  },
  contracts: {
    provides: {
      httpApiResourceContract: httpApiResourceContract.fullContractSchema,
    },
    consumes: {},
  },
  resources: {
    Description: 'Core service',
    Outputs: {
      HttpApiId: httpApiResourceContract.exportValue({
        description: 'The shared httpApi resource',
        value: { Ref: 'HttpApi' },
      }),
    },
  },
};

Command name and used flags

serverless deploy

Command output

Environment: linux, node 14.18.2, framework 3.1.1 (local), plugin 6.0.0, SDK 4.3.1
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Cannot resolve serverless.ts: "provider.profile" property is not accessible (configured behind variables which cannot be resolved at this stage)

Environment information

Framework Core: 3.1.1 (local)
Plugin: 6.0.0
SDK: 4.3.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
fargitocommented, Feb 10, 2022

I can confirm that this issue is fixed with version 3.2.0

1reaction
fargitocommented, Feb 7, 2022

Thanks a lot 🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stages included from stageList parameter can't use built-in ...
I have a build template where I'm using the "stageList" variable type, like this: parameters: - name: additionalStages displayName: Additional stages to ...
Read more >
Troubleshoot CI-CD, Azure DevOps, and GitHub issues
Customer followed all necessary steps like installing NPM package and setting up a higher stage using Azure DevOps, but deployment still fails.
Read more >
sam deploy - AWS Serverless Application Model
When you perform subsequent deployments of your application using sam deploy, the AWS SAM CLI retrieves the required parameters from the configuration file....
Read more >
Create a CI/CD pipeline for .NET with the DevOps Starter Project
NET sample DevOps project using DevOps Starter feature in Azure ... Settings if you would like to edit web app and database parameters....
Read more >
Troubleshooting CI/CD - GitLab Docs
Common CI/CD issues · Jobs or pipelines don't run when expected · Pipeline with many jobs fails to start · A job runs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found