[Asgard is deprecated at Netflix. We use Spinnaker ( www.spinnaker.io ).] Web interface for application deployments and cloud management in Amazon Web Services (AWS). Binary download: http://github.com/Netflix/asgard/releases
contains a non working example on how to extend the user data to provide custom environment variables.
This line creates a new instance of DefaultUserDataProvider which is outside the scope of Spring autowire control, so when the defaultProvider.buildUserDataForVariables method is invoked it causes a method inside with an autowired object method to be called result in a null pointer exception.
DefaultUserDataProvider defaultProvider = new DefaultUserDataProvider()
The proposed change to the example would be, this would then provide access to the defaultProvider with all autowired dependencies calls made inside the provider.
Builds user data Initech style.
*/
class InitechAdvancedUserDataProvider implements AdvancedUserDataProvider {
@Autowired
DefaultUserDataProvider defaultProvider
The wiki at https://github.com/Netflix/asgard/wiki/Customizing-User-Data
contains a non working example on how to extend the user data to provide custom environment variables.
This line creates a new instance of DefaultUserDataProvider which is outside the scope of Spring autowire control, so when the defaultProvider.buildUserDataForVariables method is invoked it causes a method inside with an autowired object method to be called result in a null pointer exception. DefaultUserDataProvider defaultProvider = new DefaultUserDataProvider()
The proposed change to the example would be, this would then provide access to the defaultProvider with all autowired dependencies calls made inside the provider.
import com.netflix.asgard.userdata.DefaultUserDataProvider import com.netflix.asgard.UserContext import com.netflix.asgard.plugin.AdvancedUserDataProvider import com.netflix.asgard.model.LaunchContext import javax.xml.bind.DatatypeConverter import com.amazonaws.services.ec2.model.Image import org.springframework.beans.factory.annotation.Autowired
/**
Builds user data Initech style. */ class InitechAdvancedUserDataProvider implements AdvancedUserDataProvider { @Autowired DefaultUserDataProvider defaultProvider
String buildUserData(LaunchContext launchContext) { // Start with Asgard's default user data UserContext userContext = launchContext.userContext String appName = launchContext.application?.name ?: '' String asgName = launchContext.autoScalingGroup?.autoScalingGroupName ?: '' String lcName = launchContext.launchConfiguration?.launchConfigurationName ?: '' String encoded = defaultProvider.buildUserDataForVariables(userContext, appName, asgName, lcName) String defaultUserData = new String(DatatypeConverter.parseBase64Binary(encoded))
} }