Hi All, Has anybody perhaps had any luck with usin...
# guide
m
Hi All, Has anybody perhaps had any luck with using "arm64" architecture for Lambdas? I was thinking that perhaps Api construct with its DefaultFunctionProps like below could be a place to use it (as below), but I cannot find in in any documentation. Has anybody had any insights? :
Copy code
import { Architecture } from "@aws-cdk/aws-lambda";
...
  app.setDefaultFunctionProps({
    timeout: 120,
    memorySize: 256,
    architecture: Architecture.arm64,
    ....
r
Yeah, this works for me
Copy code
import { Architecture } from '@aws-cdk/aws-lambda';

// default to ARM architecture but allow override if we're in a region that doesn't support it
const architecture = process.env.LAMBDA_ARCHITECTURE === 'ARM_64' ? Architecture.ARM_64 : Architecture.X86_64;

export default function main(app: <http://sst.App|sst.App>): void {
  app.setDefaultFunctionProps({
    runtime: 'nodejs14.x',
    architectures: [architecture],
  })
  ...
}
m
Ross, thanks so much! Works like a charm ๐Ÿ™‚๐Ÿ‘
r
Good stuff
I found out that some regions (us-west-1 for example) don't support the new architecture yet, hence the option in the code
c
@Ross Coundon do you happen to know how to check which regions support ARM_64? I tried the following to test things in us-east-1 and still seem to be getting x86_64
r
Not programmatically, the press release document does mention which though
c
Thanks. Was able to find that now and it looks like it should be available in US East. Not sure yet why itโ€™d keep defaulting new functions to old architecture. Will have to keep playing it with a bit
r
I don't think it's the default, I think you have to specify
c
Thanks Ross. I may have presumed
process.env.LAMBDA_ARCHITECTURE
was something that the region set/dictated. Is this something you are setting manually within the account in addition to updating the stack index with that code?
r
We set that env var in our own stack. We used to default to the ARM_64 arch but then discovered it wasn't supported everywhere, so we set it in Seed according to what's available in the deployed region. We actually default to X86_64 as we know that's supported everywhere i.e.
Copy code
const architecture = process.env.LAMBDA_ARCHITECTURE === 'ARM_64' ? Architecture.ARM_64 : Architecture.X86_64;
c
Ah, ok. Thanks again Ross.
s
@Ross Coundon are you seeing a good performance boost/cost savings with arm64?