I am getting the below error when I am trying to run a Spring boot-AWS application locally :
There is not EC2 meta data available, because the application is
This proved a little tricky for me to solve.
Using the information from souvikc above: https://stackoverflow.com/a/45853793/1279002
and
here: https://stackoverflow.com/a/55255504/1279002
I came up with (I'll take the hard coded region out eventually but just elated it finally works!):
@Configuration
@EnableContextInstanceData
@EnableSqs
@Profile("!local")
@Slf4j
public class AwsEc2Config {
@Bean
public RegionProvider regionProvider() {
return new StaticRegionProvider("eu-west-1");
}
@Bean
public SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory(AmazonSQSAsync amazonSQS) {
SimpleMessageListenerContainerFactory factory = new SimpleMessageListenerContainerFactory();
factory.setAmazonSqs(amazonSQS);
factory.setMaxNumberOfMessages(10);
factory.setAutoStartup(true);
factory.setWaitTimeOut(20);
return factory;
}
}